in reply to How to get last month date using Date::Calc

When the day (and time) is not involved, your question does not need Date::Calc or anything fancy.

$ perl -wE'my($m,$y)=(localtime)[4,5];--$m<0 and($m,$y)=($m+12,$y--);s +ay $m+1,"-",$y+1900;' 9-2018

or as sub

sub previous_month { my ($month, $year) = @_; # month = 1..12 if (--$month < 1) { $month = 12; $year--; } ($month, $year); } # previous_month say for previous_month (10, 2018);

Enjoy, Have FUN! H.Merijn