Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Logging Singleton

by tobyink (Abbot)
on Feb 18, 2013 at 16:51 UTC ( #1019366=note: print w/ replies, xml ) Need Help??


in reply to Logging Singleton

It's probably overkill. You could do this...

# SUBS my $log = Log->new(); sub do_this{ $log->log('Log This'); } sub do_that{ $log->log('Log That'); }

Or even this...

# SUBS my $log; sub do_this{ ($log||=Log->new)->log('Log This'); } sub do_that{ ($log||=Log->new)->log('Log That'); }
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name


Comment on Re: Logging Singleton
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2014-09-19 22:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (149 votes), past polls