in reply to Find a file

In general, you'll need to examine all the file names that could be the most recent one, and determine the most recent one from the names. It might be easier if you use file names of the format YYYYMMDD.txt, or some such, because then, after sorting the files, the 'last' one in the sorted list will be the one you want. (Y = year, M = month, D = day)
... # this assumes all files in the same dir opendir HANDLE, "the_dir" or die "couldnt opendir the_dir for reading $!"; my @files = readdir HANDLE; closedir(HANDLE); my $most_recent = (sort my_filename_sorter @files)[-1] ... sub my_filename_sorter { (my $a_date = $a) =~ s/\.txt$//; (my $b_date = $b) =~ s/\.txt$//; return $a_date <=> $b_date; }
I wasn't horribly terse, so hopefully this makes sense.
Of course you'll need to check for the situation where there are no files.

UPDATE: I forgot to put the final slash of the substitutions - its there now.