Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
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 having an uproarious good time at the Monastery: (16)
As of 2014-07-11 17:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (232 votes), past polls