I am experiencing some problems moving a script from Solaris running
Perl 5.8.5, to RHEL4 Linux running Perl 5.8.8.

The below script works as expected on the Solaris box, reporting the
number of lines of the file, but on the RHEL4 box it reports 0
irrespective of the number of lines in the file.

I have no idea why this isn't working on the new server, any help would
be very much appreciated.

Thanks,
Paul

#!/usr/bin/perl
use Fcntl ':flock';

my $lines = 0;
open(FILE, "+>>$ARGV[0]") || die "Unable to open $ARGV[0]\n$!\n";
flock(FILE,LOCK_EX); # Count number of lines in file while (sysread
FILE, $buffer, 4096) {
        $lines += ($buffer =~ tr/\n//);
}
flock(FILE,LOCK_UN);
print "LINES: $lines\n";

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to