Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Scoping of my with foreach loop

by Popcorn Dave (Abbot)
on Mar 07, 2005 at 19:17 UTC ( [id://437290]=note: print w/replies, xml ) Need Help??


in reply to Scoping of my with foreach loop

Other than it won't compile? You need to make that $item.

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.

Useless trivia: In the 2004 Las Vegas phone book there are approximately 28 pages of ads for massage, but almost 200 for lawyers.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2024-03-19 10:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found