Rpick has asked for the wisdom of the Perl Monks concerning the following question:
I've written the following code which does what I want,
but I want to know what PERL has built in to do this.
I've got the O'Reilly books Learning Perl and
Programming Perl, but finding the "correct" function
is proving a challenge.
All suggestions appreciated.
use strict; use warnings; my $day = (localtime)[3]; my $month = (1..12)[(localtime)[4]]; my $year = (localtime)[5] + 1900; if(length($day) < 2){ $day = "0".$day; } if(length($month) <2){ $month = "0".$month; } print "$year$month$day\n"; exit(0);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Formatting Dates
by gellyfish (Monsignor) on Feb 06, 2002 at 22:01 UTC | |
|
Re: Seeking the
by Bepa (Beadle) on Feb 06, 2002 at 21:46 UTC | |
|
Re: Seeking the
by rjray (Chaplain) on Feb 06, 2002 at 22:44 UTC | |
|
Re: Seeking the
by Spudnuts (Pilgrim) on Feb 06, 2002 at 23:39 UTC | |
|
Re: Seeking the
by data64 (Chaplain) on Feb 07, 2002 at 01:54 UTC | |
|
Re: Seeking the
by Parham (Friar) on Feb 07, 2002 at 00:37 UTC | |
|
Re: Seeking the
by Rpick (Novice) on Feb 06, 2002 at 22:25 UTC | |
by gellyfish (Monsignor) on Feb 06, 2002 at 22:30 UTC |