Chas. Owens wrote:
On Sat, Feb 7, 2009 at 19:11, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
TMTOWTDI
use Time::Local;
while (<DATA>) {
s{,(.+?),}{
my ($d, $m, $y) = split /\//, $1;
my $t = timelocal 0, 0, 0, $d, $m-1, $y;
($d, $m, $y) = (localtime $t)[3..5];
sprintf ',%d-%02d-%02d,', $y+1900, $m+1, $d;
}e;
}
snip
And this would be the confusing, fragile mess I spoke of.
Sorry, but I fail too see how using the s/// operator to extract the
date field would be so much more confusing and fragile compared to
split() + join().
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/