Mathew Snyder schreef:
> I need to make sure $day and $month are in 2-digit format
Don't mix value and presentation.
Variant-1:
perl -wle'
my $i = 0;
my ($day, $month, $year) =
map $_ + (0, 1, 1900)[$i++], (localtime)[3..5];
printf qq/%04d %02d %02d\n/, $year, $month, $day;
'
Variant-2:
$ perl -wle'
my ($day, $month, $year) =
map {"0,1,1900"=~/(\d+)/g; $_+$1} (localtime)[3..5];
printf qq/%04d %02d %02d\n/, $year, $month, $day;
'
In Perl6 this can (AFAIK) look like
my ($day, $month, $year) = (localtime)[3..5] >>+<< (0, 1, 1900);
(see Perl6 hyperoperators)
--
Affijn, Ruud
"Gewoon is een tijger."
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/