Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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 scrutinizing the Monastery: (10)
As of 2014-09-22 15:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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











    Results (198 votes), past polls