----- Original Message -----
From: Kevin Old <[EMAIL PROTECTED]>
Date: Tuesday, September 13, 2005 5:31 am
Subject: Help with sprintf
> Hello everyone,
Hello,
> My result is: 20050901, but what I'm trying to get is 050901.
>
You can try with two possibilities:
1. Using Mod 100 on the year.
$ perl -e '
@time = localtime();
$time[4]++;
$time[5] += 1900;
$lastmonday = sprintf("%02d", $time[5] % 100) . sprintf("%02d", $time[4]) .
"01";
print "$lastmonday\n"'
2. Use POSIX module
$ perl -MPOSIX=strftime -e '
my $time = time;
$time -= 24*60*60*( strftime('%u', localtime($time)) - 1);
print strftime ':%y%m%d',
'
> Any ideas what I'm doing wrong?
>
Regards,
Edward WIJAYA
SINGAPORE
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>