Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks!
What is the best way to get the full name of last month with Time::Piece.
#!/usr/bin/perl use strict; use warnings; use Time::Piece; use Time::Seconds; my $t = Time::Piece->new(); my $l_month = $t->month(-1); print "\n 1) - L Month $ l_month\n"; my $last_month = $t->fullmonth(-1); print "\n 2) - L Month $ last_month\n"; my $lastmonth = $t->add_months(-1); print "\n 3) - L Month $ lastmonth\n";

Thanks!

Replies are listed 'Best First'.
Re: Get last month's name with Time::Piece
by toolic (Bishop) on Nov 11, 2014 at 18:29 UTC
    One way:
    use warnings; use strict; use Time::Piece; my $t = Time::Piece->new(); my $lastmonth = $t->add_months(-1); print $lastmonth->strftime('%B'), "\n"; __END__ October