in reply to Find a file

If I underastand you correctly, you have a program that does two things: first it appends data to a file named after today's date, eg a log file; second, if that file doesn't exist, then it first finds the most recent file with an older date in its filename, then creates the new file.

I would recomment choosing a filename format that sorts alphabetically the same as cronologically, eg 2004.05.11.txt. Then all you need to do is read in the current directory, do a reverse sort on the filenames, and pick the first, eg

opendir D, '.'; @files = reverse sort grep $_ ne '.' && $_ ne '..', readdir D; if (@files) { email($files[0]); }
If you can't make your filenames sort like that, then you'll need to take the extra step of splitting apart the filename, eg
@files = map { $_->[0] } sort { $b->[1] <=> $a[1] } map { /^(..)(..)(..)/; [ $_, "$3$2$1" ] } grep $_ ne '.' && $_ ne '..', readdir D;
(The above is known as a Schwartzian transform)