The trick is to use Time::Local to find the first day of the month, then subtract 1 day.
This prints: 09-2004 08-2004 07-2004 ############################### use Time::Local; use constant DAY => 86_400; $current = time; $previous = first_day($current) - DAY; $current_2 = first_day($previous) - DAY; print get_date($current), "\n"; print get_date($previous), "\n"; print get_date($current_2), "\n"; sub first_day { my $time = shift; my @time = localtime($time); $time[3] = 1; return timelocal(@time); } sub get_date { my $time = shift; my @time = localtime($time); return sprintf('%02d-%04d', $time[4]+1, $time[5]+1900); } -----Original Message----- From: Greg Schiedler [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 07, 2004 5:01 PM To: [EMAIL PROTECTED] Subject: Month-Year Links.... Perl v5.6.1 Trying to easily create some variable based on the current month and links to the two previous months. The filename(s) are based on two digit months MM-YYYY-Filename. I have the filename part working but I need some guidancd on creating the MM-YYYY. I have seen many perl modules that I could install to implement a solution but I think that is an overkill just to make create a current month, previous month and two months ago variables. RedHat ish OS Cobalt RaQ4i to be specific.... ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); Ie. $current = "09-2004-Filename" $previous = "08-2004-Filename" $current_2 = "07-2004-Filename" Does anyone have a simple solution? Greg -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>