- or download this
use warnings;
use strict;
...
$log->log('default log message');
$log->log('alternate log file msg', 'not-default.log');
}
- or download this
$ cat default.log
default log message
- or download this
$ cat non-default.log
alternate log file msg
- or download this
sub log {
my ($self, $msg, $log) = @_;
...
# use the default fh
$log_fh = $self->{default_log};
}
- or download this
open my $fh, '>>', 'alternate.log' or die $!;
$log->log('msg', $fh);