use strict; use warnings; use POSIX qw(strftime); print strftime("arident16_%b%e%Y_2358.zip\n", gmtime); output: arident16_Jul292009_2358.zip #### ### at the top of the file: use POSIX qw(strftime); ### ... ### just before your foreach loop: my $files_to_match = strftime("%b%e%Y_2358.zip", gmtime); foreach $file (@list) { # N.B. I am assuming $file contains the filename here. # skip files that don't end with $files_to_match # N.B. could use regex here, not sure what's faster. next unless substr($file, 0 - length($files_to_match)) eq $files_to_match; ### Then what you did already. I didn't check that. } ### quit, etc...