Kevin Old wrote: > Hello everyone, Hello,
> I'm having trouble with sprintf. I know it's some silly mistake I'm > making, but can't seem to figure it out. > > Here's what I have: > > my @time = localtime(); > $time[4]++; > $time[5] += 1900; > my $lastmonday = sprintf("%02d", $time[5]) . sprintf("%02d", $time[4]) . '01'; > > My result is: 20050901, but what I'm trying to get is 050901. > > Any ideas what I'm doing wrong? You have to make the year a two digit number in order to display it correctly. my @time = localtime; $time[4]++; $time[5] %= 100; my $lastmonday = sprintf '%02d%02d01', @time[5,4]; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>