use Date::Calc qw(Today Days_in_Month); my ($year, $month, $day) = Today(); return Days_in_Month($year,$month - 1);