On Sat, Feb 7, 2009 at 19:11, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote: > Chas. Owens wrote: >> >> On Sat, Feb 7, 2009 at 16:09, Gunnar Hjalmarsson <nore...@gunnar.cc> >> wrote: >>> >>> Chas. Owens wrote: >>>> >>>> This isn't a job for a regex; it is a job for split: >>> >>> whose first argument is a regex pattern... ;-) >> >> snip >> >> Yes and a regex follows in the substitute, but the whole things isn't >> being done with a regex. Trying to do it with one regex can lead to a >> confusing and fragile mess. > > 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. -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/