sub StartLogging { our $ref = shift @_; # ref to config hash our ($file, $level); BEGIN { $file = $ref->{log}{file_base} . ".$ref->{hostname}{target}.$0.$$.log"; $level = $ref->{log}{level}; } if ( $ref->{log}{method} eq "StdLog" ) { print "Logging to file $file at minimum loglevel $level\n"; use Log::StdLog { level => $level, file => $file, }; #now, log messages can be written to {*STDLOG} my $print_rc = print {*STDLOG} warn => "warn - this is a test"; } }