Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://747061]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2016-12-03 01:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (51 votes). Check out past polls.