How can I 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 20:23 UTC
Read the original article Hit count: 120

Filed under:
|

I have created a file argument.pl which takes several arguments first of which should be in form of a year For example: 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 fills $Year with "current year" if $ARGV[0] is null or doesn't exist. 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