Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
package Log; my $singleton; sub new { # Check to see if we have a Log instance # Otherwise return singleton unless ( $singleton ){ my ($class,$path) = @_; $singleton = {}; bless $singleton, 'Log'; $singleton->create_logfiles($path); } return $singleton; } sub create_logfile{ create logfile } sub log { print to logfile } # SUBS sub do_this{ my $log = Log->new(); $log->log('Log This'); } sub do_that{ my $log = Log->new(); $log->log('Log That'); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Logging Singleton
by tobyink (Canon) on Feb 18, 2013 at 16:51 UTC | |
|
Re: Logging Singleton
by 7stud (Deacon) on Feb 18, 2013 at 17:26 UTC | |
by Anonymous Monk on Feb 18, 2013 at 19:34 UTC | |
|
Re: Logging Singleton
by blue_cowdawg (Monsignor) on Feb 18, 2013 at 18:45 UTC | |
|
Re: Logging Singleton
by manorhce (Beadle) on Feb 18, 2013 at 18:56 UTC | |
by Anonymous Monk on Feb 18, 2013 at 19:23 UTC |