Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Using and renaming same variables/hash within different subroutines

by why_bird (Pilgrim)
on Jun 24, 2009 at 08:26 UTC ( #774300=note: print w/replies, xml ) Need Help??


in reply to Using and renaming same variables/hash within different subroutines

...so that it won’t collide with same variable within another subroutine...
There shouldn't be any collision, if you 'my' something within a subroutine, that variable should be scoped only to the end of that block (i.e. to the end of the subroutine). So you can call two variables in two different subroutines the same thing.

Look here for a good explanation of 'lexical scoping' (i.e. declaring variables with 'my')

why_bird
edit: added link
........
Those are my principles. If you don't like them I have others.
-- Groucho Marx
.......
  • Comment on Re: Using and renaming same variables/hash within different subroutines

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2021-10-23 23:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (88 votes). Check out past polls.

    Notices?