in reply to Scoping of my with foreach loop
And yes you could concievably run in to scoping issues. Someone else will correct me if I'm incorrect about this but I believe that if for example, you declare my $item at the top of your program, then it's got global scope. However if that foreach loop was placed in a subroutine then it's going to be local to that routine and you wouldn't have access to it outside the loop.
If both of those are at the top of a script, then there shoudln't be any difference.
Update:Fletch picked up what I failed to take in to account completely about being visible within the foreach loop.
|
|---|