use strict; use warnings; use Time::Piece; my @str = ( 'Thu Oct 9 16:58:28 2003', 'Mon Nov 10 06:08:08 2003', 'oops', ); for (@str) { my $time; eval { $time = Time::Piece->strptime($_,'%a %b %d %T %Y'); }; warn "bad time: '$_'\n" and next if $@; print join(',', map $time->$_, qw(second minute hour fullday fullmonth year) ); }