Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Having to specify $_

by sauoq (Abbot)
on Dec 09, 2002 at 03:15 UTC ( [id://218440]=note: print w/replies, xml ) Need Help??


in reply to Having to specify $_

Functions do not assign to $_ by default. Consider

sub foo { 'foo' }; foo(); print $_,"\n";
You wouldn't expect that to print 'foo', would you? Well, the while loop doesn't make it any different. You have probably been confused by things like while (<>) {} (which works because <> assigns to $_ by default) and for (@list) {} which works because for will use $_ by default when an iteration variable isn't named.

-sauoq
"My two cents aren't worth a dime.";

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-19 21:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found