http://qs1969.pair.com?node_id=439323

drock has asked for the wisdom of the Perl Monks concerning the following question:

All, I want to be able to pass by reference into my logroll (). I have tried various code changes, but nothing is working. The line I am having issues with is &logroll($fujitapeszs); It looks like logroll is reading the file contents???

Error string reads: Uncaught exception from user code: error: can not lock open: ( sf.F02002capacity: 189.1G 4 Carp::croak('error: can not lock open:(sf.F02002 Logfile::Rotate::new('Logfile::Rotate', 'File', ' sf.F02002 4 main::logroll('/usr/local/log/fuji_tapeszs.log') called at tapesz_chk. +O0 ####################################### ## Set pragmas and modules (LC/UC) ## ####################################### require 5.6.1; use strict; use warnings; use diagnostics; use MIME::Lite (); use Logfile::Rotate (); $ENV{"PATH"} = qq(/opt/SUNWsamfs/sbin:/usr/bin:/usr/sbin:/usr/local/lo +g); my $wd=40; my $tpexports = qq(/usr/local/log/exports); my $hrtlabtapeszs = qq(/usr/local/log/heartlab_tapeszs.log); my $fujitapeszs = qq(/usr/local/log/fuji_tapeszs.log); my $slhtapeszs = qq(/usr/local/log/slh_tapeszs.log); open (FFFF_, "+>$tpexports") || die "could not open file: $tpexports $ +!"; open (FFF_, "+<$hrtlabtapeszs") || die "could not open file: $hrtlabta +peszs $!"; open (FF_, "+<$fujitapeszs") || die "could not open file: $fujitapeszs + $!"; #open (F_, "+<$slhtapeszs") || die "could not open file: $slhtapeszs $ +!"; system("archiver -lv|egrep 'sf.H02[0-9][0-9][0-9]' > $hrtlabtapeszs"); system("archiver -lv|egrep 'sf.F02[0-9][0-9][0-9]' > $fujitapeszs"); #system("archiver -lv|egrep 'sf.L02[0-9][0-9][0-9]' > $slhtapeszs"); select( (select(FFFF_), $|=1 ) [0] ); select( (select(FFF_), $|=1 ) [0] ); select( (select(FF_), $|=1 ) [0] ); #select( (select(F_), $|=1 ) [0] ); while (<FFF_>) { if (substr($_, 52, 5) == 0 ){ chomp $_; my $hvalustr=substr($_, 52, 5); my $htpstr=substr($_, 2, 9); #system("samexport $htpstr"); #&logroll(); print FFFF_ "$htpstr\t$hvalustr\n"; } } while (<FF_>) { if (substr($_, 52, 5) == 0 ){ chomp $_; my $fvalustr=substr($_, 52, 5); my $ftpstr=substr($_, 2, 9); #system("samexport $ftpstr"); &logroll($fujitapeszs); print FFFF_ "$ftpstr\t$fvalustr\n"; } } #while (<F_>) { # if (substr($_, 52, 5) == 0 ){ # chomp $_; # my $svalustr=substr($_, 52, 5); # my $stpstr=substr($_, 2, 9); # system ("samexport $stpstr"); # &logroll($slhtapeszs); # print FFFF_ "$stpstr\t$svalustr\n"; # } #} if ( -s $tpexports ) { print FFFF_ "\n",'-' x $wd, "\n"; print FFFF_ "TapeID\t BytesRemaining\n\n"; print FFFF_ "Please eject these as offsite permanent!\ +nOhioHealt h Unix Support"; #&mailme; #&logroll; } sub mailme { my $msg = MIME::Lite->new( From => 'stkv440 <root@>', #To => 'OHIS Operations <oper1@>', To => 'Derek Smith <dbsmith@>', Subject => "ASM Copy 2 exports", Type => 'multipart/related'); $msg->attach( Type => 'TEXT', Path => "$tpexports", Filename => "$tpexports"); #$msg->send; } #foreach ($fujitapeszs,$hrtlabtapeszs,$tpexports,$slhtapeszs) +{ #if ( -s $_ or -s $_ or -s $_ or -s $_ ) { #foreach ($_) { sub logroll { my $logs = new Logfile::Rotate (File => $_, Count => 10, Gzip => 'lib', Dir => '/usr/local/lo +g/old', Flock => 'yes', Persist => 'yes' ); $logs->rotate(); } #} #} #} #close (F_) or warn "unable to close file $!"; close (FF_) or warn "unable to close file $!"; close (FFF_) or warn "unable to close file $!"; close (FFFF_) or warn "unable to close file $!";

2005-03-14 Janitored by Arunbear - added readmore tags, as per Monastery guidelines