Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
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?
[marto]: failing that see the README
[mark4]: I installed "PAR" from the ppm install window. pp.exe. did not show up.
[marto]: it should just be a script, pp, or on windows pp.bat, post install you should just be able to call pp -x packed.exe source.pl as the PPM package should put everything required into the appropriate path
[marto]: ah, some time ago pp became it's own package, try searching your repo for PAR::Packer
[marto]: again, Strawberry + cpanm for the win: cpanm pp to install

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2018-01-19 14:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (218 votes). Check out past polls.

    Notices?