On Aug 31, [EMAIL PROTECTED] said: > open(FILE, "> $logfile") or die "Couldn't open $logfile : $!\n"; # This > logfile keeps appending in a linux m/c > flock(FILE,2); > while (sysread FILE, $buffer, 4096) { > $lines += ($buffer =~ tr/\n//); > }
This makes NO sense. You've opened the file for *writing*, not reading. I think what you want to do is: use Fcntl; open FILE, "+>> $logfile" or die "can't r/w append to $logfile: $!"; flock FILE, LOCK_EX; seek FILE, 0, 0; # you need to go to the front first 1 while <FILE>; $lines = $.; seek FILE, 0, 0; truncate FILE, 0; print FILE "whatever\n"; close FILE; -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overpaid? http://www.perlmonks.org/ % -- Meister Eckhart -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>