Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: _ doing something new to me?

by Lawliet (Curate)
on Feb 28, 2009 at 01:32 UTC ( #747061=note: print w/ replies, xml ) Need Help??


in reply to _ doing something new to me?

It is basically the same thing as the last "thing" tested with the previous test operator but without having to re-test it (which is apparently expensive). I remember reading that in a book.

Update: I think it is called 'chaining' tests.

Update2:

To save the overhead of a low-level stat() system call, Perl caches the previously-examined inode in a special variable called simply '_'; so we can do tests like this:
if ( -e $file && -r _ && -x _) { # $file exists and is both readable and executable ... }

And you didn't even know bears could type.


Comment on Re: _ doing something new to me?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (13)
As of 2015-07-06 22:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (83 votes), past polls