Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Finding oldest file in directory

by Roy Johnson (Monsignor)
on Oct 18, 2004 at 19:12 UTC ( #400283=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my $oldest;
    my $oldtime = 0;
    ...
        ($oldest, $oldtime) = ($_, $thistime);
      } 
    }
    
  2. or download this
    use List::Util 'reduce';
    my $file = (reduce {$a->[0] < $b->[0] ? $a : $b}
                       map {[(stat)[10],$_]}
                       glob '*.pl'
               )->[1];
    
  3. or download this
    my $file = reduce {(stat $a)[10] < (stat $b)[10] ? $a : $b}
                      glob '*.pl';
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://400283]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2014-09-21 16:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (172 votes), past polls