Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: Packaging up my code sensibly

by punkish (Priest)
on Jun 12, 2005 at 16:23 UTC ( [id://465976]=note: print w/replies, xml ) Need Help??


in reply to Re: Packaging up my code sensibly
in thread Packaging up my code sensibly

Thanks for the reply. Your linked thread is quite specific to CGI::App, and while I learned a little bit from it, I am still in the confused land.

Wrt reading a conf file, that is not really a problem. I am already reading an external conf file. I can also use Config::Simple or its many other brethren. However, the problem more is how to share these values among the various imported modules. I guess, that is really what I need a tutorial on.

I am not really share my H::T objects right now. I have only one module MyPackage.pm that I bring in. I create an H::T object in it. However, if I chop up MyPackage.pm into many sub-packages, I will have to schlep H::T object back and forth. I am not quite sure how to do that correctly.

--

when small people start casting long shadows, it is time to go to bed

Replies are listed 'Best First'.
Re^3: Packaging up my code sensibly
by wazoox (Prior) on Jun 13, 2005 at 10:19 UTC
    Isn't what you need is a singleton object to store your values? Something that you'll call like this :
    use MyModules::Config; # here's the singleton magic: # "new" recalls the existing instance if any. my $conf=Config->new();
    from each script. And the Config package would look like this : This way, all your modules can share the same config without passing any parameter around : just call my $conf=Config->new() from each module, the first to call it will load the configuration data, the others will simply share that instance.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-24 06:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found