Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: grab newest file

by jwkrahn (Abbot)
on Jul 07, 2006 at 00:06 UTC ( [id://559697]=note: print w/replies, xml ) Need Help??


in reply to Re^2: grab oldest file
in thread grab newest file

If you really want to use the least resources: Updated for newest file:
my $report = do { opendir my $dh, $path or die "open '$path' $!"; my ( $name, $mtime ) = ( '', ~0 ); while ( my $file = readdir $dh ) { stat "$path/$file"; ( $name, $mtime ) = ( $file, -M _ ) if $file =~ /B1006/ and $m +time > -M _; } $name; };

Replies are listed 'Best First'.
Re^4: grab newest file
by shmem (Chancellor) on Jul 07, 2006 at 06:36 UTC
    Comparing mtime (timestamp) and -M is bogus. -M gives you the script start time minus file modification time, in days.

    update - oops, sometimes I'm a lousy reader - the referred post compares only -M against -M. Read the above just as a general statement ;-)

    thanks jwkrahn

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
      The code I posted is only comparing the -M value with other -M values. The $mtime in the code is just a variable name.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-24 08:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found