I do not think you need to write a regex. I think one of the data modules
can do the conversions for you.
Try Date-Manip using UnixDate ($olddate"%m/%d/%y %r"). This is the
slowest of the Date routines so there may be another one to try.
Scott
"Doug Brewer" <[EMAIL PROTECTED]>
Sent by: To:
"perl-win32-users"
[EMAIL PROTECTED]
<[EMAIL PROTECTED]>
eState.com cc:
Subject: regex -
conditionals?
01/04/01 10:22 AM
I have a regex question. I need to convert a tab delimited file of date and
time
values to a different format.
I need to get to:
YYYY-MM-DD HH:MM:SS
what i'm starting with is:
4/23/1998 4:55:37 PM
^ ^ these need to be 2 digits
The difficulty I'm having is not reversing the date value, or converting
the
time value to 24 hours from a 12 hour am/pm. I am having difficulty making
sure
that the HH:MM:SS are all two digits, and the same with the MM-DD portion
of the
date.
For instance, I am using this to reverse the date (and change the
separators):
$line =~ s|(.*)/(.*)/(.*)\t|$3-$2-$1\t|g;
but how do I conditionally add a leading zero if $2 or $1 are of length==1?
TIA,
Doug Brewer
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users