Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^5: looking for a good idiom: return this if this is true

by merlyn (Sage)
on Mar 07, 2005 at 19:25 UTC ( [id://437292]=note: print w/replies, xml ) Need Help??


in reply to Re^4: looking for a good idiom: return this if this is true
in thread looking for a good idiom: return this if this is true

$_ is set by very few things:
  • An explicit assignment ($_ = 35).
  • The implicit setting for a while() loop reading from a filehandle:
    while (<HANDLE>) { ... } # same as ... while (defined($_ = <HANDLE>)) { ... }
  • The implicit variable of a foreach loop:
    foreach (@list) { ... } # same as foreach $_ (@list) { ... }
  • The implicit variable of a grep/map block (added after prodding, sorry):
    $count = grep { BLOCK } LIST; @result = grep { BLOCK } LIST; @result = map { BLOCK } LIST; map { BLOCK } LIST; # invalidates your warranty
I think that's it. I don't recall anything else that can set the value. Lots of operations can alter the value, like chomp or s///.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-18 18:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found