Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Question regarding variable scope

by Enlil (Parson)
on Oct 16, 2003 at 06:40 UTC ( [id://299680]=note: print w/replies, xml ) Need Help??


in reply to Question regarding variable scope

I've observed the same result when I declare the variable with our as well. It seems like the foreach loop is using local internally. Is that the case?

Take a look at perldoc perlsyn (the section on Foreach) for more information but the short answer is yes.

and is there a way to get the behavior I'm looking for, short of using some kind of intermediate variable?

As Roger shows above just change your looping variable, and set $black_player to the value you before you exit the loop.

-enlil

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-19 02:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found