"Jason Balicki" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I've got a phone record that keeps the date and time > in the following format: > > YYMMDDHHMM > example: 0501201500 > > So, I've written the following to convert it to the > format: > > MM/DD/YYYY,HH:MM > example: 01/20/2005,15:00 > > <snip /> > > This works, but strikes me as ugly. Is there a more > elegant way of doing what I've done here? It seems > like I should be able to loop through the $ardate[n] > entries and select them somehow instead of hard coding > the indexes, but nothing is coming to mind. >
You want to use the C strptime finction. Theres several ways to use it inside perl. I like Time::Piece: [EMAIL PROTECTED] trwww]$ perl use warnings; use strict; use Time::Piece; my $time = Time::Piece->strptime('0501201500','%y%m%d%H%M'); print $time->datetime, "\n"; Ctrl-D 2005-01-20T15:00:00 Install and read the docs for Time::Piece. Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>