Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: localization of $_

by TheoPetersen (Priest)
on Feb 28, 2001 at 00:03 UTC ( [id://61150]=note: print w/replies, xml ) Need Help??


in reply to localization of $_

It's a common enough situation. I think a lot of us figured it out in just this way too.

perlman:perlsub, perlman:perlsyn and perlman:perlvar all have some comments about this, but it can be hard to get the picture from those without someone (or some bug) pointing it out. perlman:perlvar states that $_ is assigned to in your while case, but doesn't make it clear that $_ isn't localized by while as a foreach would.

Either localize $_ yourself, or switch to another while style for any loop that calls subroutines: while (my $line = <FILE>) {

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-04-26 08:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found