Either of these will work -- I'll leave it up to the experts to let us know
which one (if any) is faster or more efficient:
$last_open = sprintf '%04d-%02d-%02d', $data[0]->[17] =~
/^(\d{4})(\d{2})(\d{2})$/;
$last_open = sprintf '%04d-%02d-%02d', unpack 'A4A2A2', $data[0]->[17];
Please note that you should be using $ instead of @ to refer to a scalar
value, and that you should use %02d as the format for a 2-digit number if
you want leading zeroes.
-----Original Message-----
From: Derrick (Thrawn01) [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 10, 2001 3:57 PM
To: Perl Beginners
Subject: printf to convert 200010809 to 2001-08-09
@data[0]->[17] contains "20010809"
I've been tring to use printf to convert the 200010809 value out as
2001-09-08
$last_open = sprintf "%4d-%2d-%2d",@data[0]->[17];
However this does not work. I get "20010809- 0- 0"
Any sugesstions on how I should make this converstion with out adding alot
of overhead doing it ?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]