Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Global variable vs passing variable from sub to sub

by edan (Curate)
on Sep 13, 2004 at 17:46 UTC ( #390618=note: print w/replies, xml ) Need Help??


in reply to Global variable vs passing variable from sub to sub

I'm surprised nobody has mentioned it yet, but this is one of the aspects or programming that Objects have come to solve. Namely, this is solved by encapsulation. That's when you hide your data (those pesky global variables) inside the object, and then you attach methods to the object to handle the data, and it all happens in a nice, self-contained (encapsulated, you might say) way.

It's not hard to write your own little module implementing a class which wraps up the global variables and their associated methods. See perltoot for more info.

--
edan

  • Comment on Re: Global variable vs passing variable from sub to sub

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2016-09-25 06:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (464 votes). Check out past polls.