Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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 ( #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
Node Status?
node history
Node Type: note [id://703039]
help
Chatterbox?
[Discipulus]: LA something a little more perlish? @mts = map {qx!mp3info -p $_!} glob '/path/*.mp3 (hazarded code)
[Discipulus]: many monks want to be hired tonight, other haired and some aired
[Lady_Aleena]: Discipulus, do glob recurse?
[Lady_Aleena]: s/do/does/;
LanX wants to be fired
[Discipulus]: i fear no
[Discipulus]: i invented also 'gired'

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (10)
As of 2017-04-23 20:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (432 votes). Check out past polls.