newbie01 perl <newbie01.p...@gmail.com> asked: > Unfortunately, I suddenly have to to deal with an input file where the > datetime format is 02-Apr-2010 3:41:23 p.m., i.e. DD-MON-YYYY HH:MI:SS > a.m./p.m., so now my Delta_YMDHMS does not work as expected.
You can convert from a.m./p.m. to standard 24 hours using a simple RE: #!/usr/bin/perl -w use strict; while( my $line = <DATA> ){ $line =~ s/(\d+)(:\d+:\d+)\s+(a|p)\.m\./($3 eq 'a')?($1%12).$2:($1%12+12).$2/e; print $line; } __DATA__ 02-Apr-2010 12:41:23 a.m. 02-Apr-2010 12:41:23 p.m. 02-Apr-2010 3:41:23 a.m. 02-Apr-2010 3:41:23 p.m. HTH, Thomas -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/