my ($mon,$year) = (localtime())[4,5]; $year +=1900; # perl counts months begining at 0 while cal begins at 1 so # the month returned from perl's localtime is already last # month, we just need to fix for jan $mon = 12 if ! $mon; my $last_day_last_month=(split /\s/, `/bin/cal $mon $year`)[-1];