in reply to adding/subtracting calender dates

First off, there are some perl modules that do all of this stuff for you. Date::Calc and Date::Manip are both good starts. (I'm sure someone will have posted links before I finish typing this.)

But, in the interest of learning a programming trick or two, though, consider doing your month math something more like:

my @months = qw(JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC); sub change_num_to_month { my $num_month = shift; return $months[$num_month - 1]; } sub add_month { my $month = shift; my $month_num = change_month_to_num($month); $month_num++; $month_num = 1 if $month_num > 12; return change_num_to_month($month_num); } # And very similarly for subtract month
Getting the reverse lookup is slightly trickier. I'd probably convert the array into a hash, something like: (I'm sure you can do better with a map, but let's go for readibilty first.)
my %month_nums; for (my $i = 0; $i <= $#months; $i++) { $month_nums{$month[$i]} = $i; } # This creates a hash of 'Jan' => 0, 'Feb' => 1, etc. sub change_month_to_num { my $month = shift; return $month_nums{$month} + 1; }
One has to be careful about the array index starting at 0, if you want your month nums to range from 1 to 12, but that's the only really tricky bit.

-- Kirby, WhitePages.com