Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Creating 'universal' instances of objects?

by jonadab (Parson)
on Aug 04, 2003 at 18:32 UTC ( #280753=note: print w/replies, xml ) Need Help??


in reply to Creating 'universal' instances of objects?

The singleton class idea is probably best, but here is another option: your main script could create your one instance and assign it to a global variable, which the other modules could access at will. Something like the following then would be at the top of each file:

use Login; use Config; our ($login, $config) = (Login::new(), Config::new());

This is in some ways less elegant than the singleton, but it leaves you the option that some modules can create their own instances if desired, but others can use the main instance.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://280753]
help
Chatterbox?
[LanX]: Robby Dobby no IIRC Sinai is already part of Asia
[robby_dobby]: blogs.perl.org page for yapceu is out of date by 2 years
[robby_dobby]: LanX: Sharm-el-Sheikh is in Egypt
[choroba]: act.yapc.eu
[robby_dobby]: Thanks, choroba
[LanX]: yes and Egypt (like Turkey and Russia) belongs to two continents
[choroba]: Also Europe and Asia are geographically one continent, the division is political
[robby_dobby]: I always thought everything on the other side of Suez to be Africa. That's an entire continent
[LanX]: Sinai_Peninsula
[robby_dobby]: choroba: If you're talking of Eurasia, it's only true of the erstwhile Constantinople/ Ottoman empire

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (13)
As of 2017-04-24 16:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (442 votes). Check out past polls.