#!/usr/bin/perl -w use strict; my %month2numstring = (Jan => '01', Feb => '02', Mar => '03', Apr => '04', May => '05', Jun => '06', Jul => '06', Aug => '08', Sep => '09', Oct => '10', Nov => '11', Dec => '12', ); while () { my $datefield = (split)[3]; my ($datestring) = $datefield=~ m|\[([\w/:]+)|; my $new_date_field = reformat_date_time($datestring); print "$new_date_field\n"; } sub reformat_date_time { my $date_time = shift; my ($date,$time) = m|([\w/]+):([\d:]+)|; my ($day,$month_text,$year) = split(m|/|,$date); $day = "0$1" if $day =~ m|^(\d)$|; #force leading zero my $month = $month2numstring{$month_text}; return ($year.'-'.$month.'-'.$day." $time"); } =prints 2010-08-21 00:00:00 2010-08-21 00:01:00 2010-08-22 01:00:00 2010-08-22 02:00:00 2010-08-22 03:04:00 =cut __DATA__ 67.162.10.216 - - [21/Aug/2010:00:00:00 +0000] GET /2010-08-18/news/ct-met-barrington-student-death-20100818_1_mental-illness-suicide-prevention-teen-suicides HTTP/1.1 200 6826 67.162.10.216 - - [21/Aug/2010:00:01:00 +0000] GET /2010-08-18/news/ct-met-barrington-student-death-20100818_1_mental-illness-suicide-prevention-teen-suicides HTTP/1.1 200 6826 67.162.10.216 - - [22/Aug/2010:01:00:00 +0000] GET /tracker.js.php?45aa01ed37b58d2a537b1ba12bb97fe2e5695a8c HTTP/1.1 200 2915 67.162.10.216 - - [22/Aug/2010:02:00:00 +0000] GET /tracker.js.php?45aa01ed37b58d2a537b1ba12bb97fe2e5695a8c HTTP/1.1 200 2882 66.249.71.98 - - [22/Aug/2010:03:04:00 +0000] GET /ad-openx.php?out=js&d=mod-top-hdr-defer&z-i=24809&z-n=top-...blah....