Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Sharing Namespaces

by skazat (Chaplain)
on Jan 27, 2006 at 09:25 UTC ( [id://525929]=note: print w/replies, xml ) Need Help??


in reply to Re: Sharing Namespaces
in thread Sharing Namespaces

Yeah, I agree with the hashref idea is cleaner, I'm just a little committed to the current interface - which is just a namespace within Config.pm that gets exported to the script that's use()ing it.

And actually, I don't see how you're idea would be any better - each module would still have to use() Config, and then go through the whole process of loading up the variables from the outside file, etc.

Actually, this is almost exactly what I"m doing :) Understood, I can just pass $conf as a paramater for say, Two.pm's new() constructer.

 

-justin simoni
skazat me

Replies are listed 'Best First'.
Re^3: Sharing Namespaces
by tirwhan (Abbot) on Jan 27, 2006 at 09:58 UTC

    That's the way I'd normally go, load your configuration once during system initialisation and then just pass the hashref/object holding this information around to other modules.

    Another way would be to use a Singleton (see for example Class::Singleton or Class:StrongSingleton). You'd still have to use and call the Config module in every other module, but Config would only load the configuration file once and just return the same instance of itself on every other call (note: this will and can not work with forked processes).


    There are ten types of people: those that understand binary and those that don't.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-03-19 10:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found