my @customerarray = ( ... ); my $now = time; my @keep = grep { my ($timestamp) = (split '::', $_)[2]; $now - $timestamp <= 15*24*60*60 # items less than 15 days old } @customerarray; open FH, '>', "$cuslist.tmp" or die "Can't open $cuslist.tmp: $!"; print FH "$_\n" for @keep; close FH;