use warnings; use strict; use Date::Calc qw/Add_Delta_YM/; sub prevmonth { my ($year, $month) = @_; my ($newyear, $newmonth, undef) = Add_Delta_YM( $year, $month, 1, 0, -1 ); return [$newyear, $newmonth]; } use Test::More; is_deeply prevmonth(2003,8), [2003,7]; is_deeply prevmonth(2004,1), [2003,12]; done_testing;