XP is just a number | |
PerlMonks |
Re: Question regarding variable scopeby Enlil (Parson) |
on Oct 16, 2003 at 06:40 UTC ( [id://299680]=note: print w/replies, xml ) | Need Help?? |
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
In Section
Seekers of Perl Wisdom
|
|