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'); }
In reply to Logging Singleton by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |