mark4444az has asked for the wisdom of the Perl Monks concerning the following question:

I am using File::Find to sort through a directory. It works, but the problem is I only want to print the latest file name. how would you do that?

Replies are listed 'Best First'.
Re: retrieve file with latest date stamp
by kennethk (Abbot) on Apr 15, 2011 at 21:54 UTC
    The -M function will return the "Script start time minus file modification time, in days." You will need to keep track of which one has the smallest value yourself, and then output the result outside of your find routine.
Re: retrieve file with latest date stamp
by JavaFan (Canon) on Apr 15, 2011 at 22:17 UTC
    I'd use:
    my $last_modified = (`ls -t`)[0];