in reply to Re: Month Dates
in thread Month Dates

I'm puzzled as to why you use a hash with December associated with zero and a modulo operation. That will only work for the first decrement of a month. To go back another month you would need a different hash with November associated with zero, and so on and so forth. I think it might be better to have a single hash with zero for January to eleven for December (as returned by localtime) and a simple algorith for decrementing the month value, something like

my %months = ( 0 => q{Jan}, 1 => q{Feb}, 2 => q{Mar}, 3 => q{Apr}, 4 => q{May}, 5 => q{Jun}, 6 => q{Jul}, 7 => q{Aug}, 8 => q{Sep}, 9 => q{Oct}, 10 => q{Nov}, 11 => q{Dec}, ); my $month = (localtime)[4]; $month --; $month = 11 if $month < 0;

This way you can keep decrementing the month until the cows come home.

Cheers,

JohnGG