Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: grab newest file

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


in reply to Re: grab newest file
in thread grab newest file

-M is 40% faster than (stat)[9], no wonder, it does look only at modification time and doesn't build a list.
It doesn't build a list but it stores all the values from stat. From the -X man page:
If any of the file tests (or either the "stat" or "lstat" operators) are given the special filehandle consisting of a solitary underline, then the stat structure of the previous file test (or stat operator) is used, saving a system call.
So when you use -M _ or -f _ you are retrieving the stored values from the previous stat or file test.

Replies are listed 'Best First'.
Re^3: grab newest file
by shmem (Chancellor) on Jul 07, 2006 at 11:52 UTC

    Right.

    If I say (stat)[9] I am building a list containing what stat returns and reference the element with index 9 in that list. If I use -M I don't create and operate on a list (although there's an underlying structure, of course).

    Getting the right element from the underlying structure directly is faster than pulling them all out and throwing away all elements but one (even though -M involves time delta calculation).

    --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}

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-03-28 17:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found