#!/usr/bin/perl use warnings; use strict; use Date::Manip qw(); # I strongly recommend version 5.54 our $TZ = 'GMT'; # to avoid error message while () { s/(-!-)/ $1/; #to deal with strange comment format my @line = split /(\s+)/; 1 while (Date::Manip::ParseDate(\@line)); $_ = (join "", @line) || "\n"; print; } __DATA__ 09:12: 5:14:29-!- {more garbage goes here} 09:12: 5:14:37 09:12: 5:14:37 2008-12-12 00:39 * {more stuff here} 2008-12-12 01:17 < {data here} 2008-12-12 01:30 2008-12-12 01:31