R
Roger
#Greetings Perl folks, I have writen the code below, and it works just like I
# want. However, as a beginner I was concerned the code was not very
# 'perl-ish' so if anyone can comment on the working code below, I'd
# be appreciative and have a nice day.
# ########################################################################## #
# Check the user input if any. If restart usage is: progname -r mm/dd/yyyy #
# ########################################################################## #
if (!@ARGV == 0) {
if ($ARGV[0] eq '-r')
{
($month, $day, $year) = split /\//, $ARGV[1];
$month = $month +0; # these strip off
$day = $day + 0; # any leading zeros
if ($month > 12 || $month < 1 || $day > 31
|| $day < 1 || $year > 2035 || $year < 2000)
{
print "\n Invalid date ".$ARGV[1]; exit; }
else {$now_date = $ARGV[1];
$file_date = substr($ARGV[1] ,0,5); $file_date =~ s/\///g;}
}
elsif ( $ARGV[0] ne '-r') {print "\n Invalid switch ".$ARGV[0]; exit;}
}
# want. However, as a beginner I was concerned the code was not very
# 'perl-ish' so if anyone can comment on the working code below, I'd
# be appreciative and have a nice day.
# ########################################################################## #
# Check the user input if any. If restart usage is: progname -r mm/dd/yyyy #
# ########################################################################## #
if (!@ARGV == 0) {
if ($ARGV[0] eq '-r')
{
($month, $day, $year) = split /\//, $ARGV[1];
$month = $month +0; # these strip off
$day = $day + 0; # any leading zeros
if ($month > 12 || $month < 1 || $day > 31
|| $day < 1 || $year > 2035 || $year < 2000)
{
print "\n Invalid date ".$ARGV[1]; exit; }
else {$now_date = $ARGV[1];
$file_date = substr($ARGV[1] ,0,5); $file_date =~ s/\///g;}
}
elsif ( $ARGV[0] ne '-r') {print "\n Invalid switch ".$ARGV[0]; exit;}
}