in reply to Re^2: Passing filename to Log::Std
in thread Passing filename to Log::Std

your code just move the problem. Try this: (untested)
sub StartLogging { my $ref = shift @_; # ref to config hash my ( $file, $level ); $file = $ref->{log}{file_base} . ".$ref->{hostname}{target}.$0.$$.l +og"; $level = $ref->{log}{level}; if ( $ref->{log}{method} eq "StdLog" ) { print "Logging to file $file at minimum loglevel $level\n"; require Log::StdLog; Log::StdLog->import( { level => $level, file => $file, } ); #now, log messages can be written to {*STDLOG} print {*STDLOG} warn => "warn - this is a test"; } }
Boris

Replies are listed 'Best First'.
Re^4: Passing filename to Log::Std
by bowei_99 (Friar) on Apr 12, 2006 at 22:33 UTC
    Hm, odd. That code crashes perl on win32, and so I think it would do the same on linux (segfault).

    Update: fixed typo, now runs with error messages:

    H:\working_files\win32>perl logtest.pl Use of uninitialized value in concatenation (.) or string at logtest.p +l line 32. Logging to file H:\working_files\test\testfile..logtest.pl.2096.log at + minimum l oglevel 'info' Unable to open log file 'H:\working_files\test\testfile..logtest.pl.20 +96.log' at logtest.pl line 46
    so, we can see that the variables in the config hash aren't being read in correctly....

    -- Burvil