in reply to Reducing repetitive code
First off, you have an error in February's conditional. Secondly, you could take advantage of perl's if-it-looks-like-a-number-it-is and do this:
my @months = qw(January February March April May June July August Sept +ember October November December); print $months[$realmonth-1];
Thirdly, since you're dealing with dates, you should probably be using one of the DateTime modules or at least POSIX::strftime.
Update: Fixed the off-by-one error in my array index.
|
|---|