in reply to
formatting integers for printing
printf("%02d/%02d/%02d", $month, $day, $year);
Assuming US centric there with variable names...
You may want to check into
sprintf
as well.
Comment on
Re: formatting integers for printing
Download
Code
Replies are listed 'Best First'.
Re: Re: formatting integers for printing
by
dws
(Chancellor)
on May 14, 2001 at 01:10 UTC
printf("%02d/%02d/%02d", $month, $day, $year);
If you're setting those variable straight from
localtime()
, and want to avoid displaying "04/13/101" intsead of "05/13/01", best use
printf("%02d/%02d/%02d", $mon + 1, $mday, $year % 100);
[reply]
[d/l]
[select]
In Section
Seekers of Perl Wisdom