in reply to Month Dates

instead of using a module, maybe you can use something like this:
my $month = (localtime())[4]; my $last_month = (($month)%12); my %months = ( 0 => "Dec", 1 => "Jan", 2 => "Feb", 3 => "Mar", 4 => "Apr", 5 => "May", 6 => "Jun", 7 => "Jul", 8 => "Aug", 9 => "Sep", 10 => "Oct", 11 => "Nov", ); print "$months{$last_month}\n";

Replies are listed 'Best First'.
Re^2: Month Dates
by johngg (Canon) on Mar 01, 2007 at 23:04 UTC
    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