On Thu, Nov 08, 2012 at 10:56:00AM +0000, Marco van Kammen wrote: > my $current_month = (should be Nov) > my $current_mont_num = (should be 11) > my $previous_month = (should be Oct) > my $previous_month_num = (should be 10)
There is Time::Piece and Time::Seconds in core since perl 5.10, so I encourage using them: use 5.010; use strict; use Time::Piece; use Time::Seconds; my $now = localtime; my $current_month_num = $now->mon; my $current_month = $now->month; # substract 3 extra days to avoid thinking about month boundaries my $previous_month_num = ($now - ($now->mday + 3) * ONE_DAY)->mon; my $previous_month = ($now - ($now->mday + 3) * ONE_DAY)->month; say "Current: $current_month_num $current_month"; say "Previous: $previous_month_num $previous_month"; Cheers, Gerhard -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/