how to identify an argument as a "Year" in PERL

Posted by dexter on Stack Overflow See other posts from Stack Overflow or by dexter
Published on 2010-03-29T10:27:15Z Indexed on 2010/03/29 10:33 UTC
Read the original article Hit count: 321

Filed under:
|

i have created a file argument.pl

which takes several arguments first of which should be in form of a year

example of argument : 2010 23 type

here 2010 is a year

my code does something like:

use strict;
use warning
use Date::Calc qw(:all);
my ($startyear, $startmonth, $startday) = Today();
my $weekofyear = (Week_of_Year ($startyear,$startmonth,$startday))[0];
my $Year = $startyear;
...
...

if ($ARGV[0])
{
$Year = $ARGV[0];
}

here this code fill $Year with "current year" if if $ARGV[0] is null or doesn't exists now here instead of if ($ARGV[0])

is it possible to check that the value in $ARGV[0] is a valid year (like 2010, 1976,1999 etc.)

© Stack Overflow or respective owner

Related posts about perl

Related posts about year