#!/usr/bin/perl -w use strict; while () { next if (!/dates processed/); my ($stamp, @dates) = ($_ =~ /(\d+-\d+-\d+)/g); # or my (undef, @dates) = ($_ =~ /(\d+-\d+-\d+)/g); # of course if that is what you want then change # the following line too! print "stamp=$stamp, dates are: @dates","\n"; } #prints...... #stamp=2009-02-19, dates are: 2009-01-31 2009-01-29 2009-01-30 #stamp=2009-02-18, dates are: 2009-02-16 2009-02-17 #stamp=2009-02-19, dates are: 2009-02-18 __DATA__ 2009-02-19 06:03:47,713 SOMETHING WRONG: 2009-01-33, 2009-01-44, 2009-01-33 2009-02-19 05 58 29 138 dates processed: 2009-01-31, 2009-01-29, 2009-01-30 2009-02-18 06:03:47,713 dates processed: 2009-02-16, 2009-02-17 2009-02-19 05:58:29,138 dates processed: 2009-02-18