Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Global variable vs passing variable from sub to sub

by edan (Curate)
on Sep 13, 2004 at 17:46 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://390618]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-19 04:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found