Greg Schiedler wrote:
> 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.
Modules? We don't need no stinking modules! :~)
my ($m, $y) = (localtime)[4, 5];
for (0 .. 2) {
printf "%02d-%04d\n", $m + 1, $y + 1900;
$m--;
$m = 11, $y-- if $m < 0;
}
Output:
09-2004
08-2004
07-2004
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>