Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Using a log object in another object without passing it as a parameter

by pc88mxer (Vicar)
on Aug 08, 2008 at 02:54 UTC ( [id://703039]=note: print w/replies, xml ) Need Help??


in reply to Using a log object in another object without passing it as a parameter

You need to use the Singleton pattern. Something like:
package Log; my $instance; ... sub get_logger { unless ($instance) { $instance = ...; # create the Log instance here # another option is to throw an exception } $instance; }
  • Comment on Re: Using a log object in another object without passing it as a parameter
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://703039]
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: (4)
As of 2024-04-20 06:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found