in reply to logfile rotate w/ pass by reference

sub logroll { my $logs = new Logfile::Rotate (File => $_, <---- your problem is here

You're not using the argument given to &logroll(), instead, you're using $_, which is set to the currently read line from one of your filehandles.

Also, proper indenting of your code will make it a lot clearer. perltidy might help.

Replies are listed 'Best First'.
Re^2: logfile rotate w/ pass by reference
by drock (Beadle) on Mar 14, 2005 at 16:51 UTC
    Thank ytou and I realize my problem where you stated. But I am unsure of the correct syntax??? I tried this:
    logroll($filename) sub logroll { my $logs = new Logfile::Rotate (File => $_, <- - - - What needs to go here?
        ok so in your sample code how does the subroutine know what variable it is receiving based off of your filename? Im ny code I have two distinct filenames I want to pass to logfile::rotate so how do I do this?
        if ( ( my $dif = $dif[1] - $dif[2] ) > 199 ) { &mailme; logroll($out); if ( ( my $diff = $diff[1] - $diff[2] ) > 199 ) { &mailme; logroll($out1); sub logroll { my $logs = new Logfile::Rotate (File => ???? # <---- what is here based? Count => 10, # off of 2 diff filenames Gzip => 'lib', Dir => '/usr/local/log/old', Flock => 'yes', Persist => 'yes' ); $logs->rotate(); }