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

Hello Monks,

I've been using a script with File::ReadBackwards for some time now, but all of a sudden, I'm getting this error:
Negative length at /usr/lib/perl5/site_perl/5.8.0/File/ReadBackwards.pm line 168.
Here's what line 168 in ReadBackwards.pm looks like:
166 # read in the next (previous) block of text 167 168 my $read_cnt = sysread( $handle, $read_buf, $read_size ) ;
I've searched this site and Google and can't find a solution. Does anyone have any ideas?

Thanks,
Dru

Replies are listed 'Best First'.
Re: Problem with File::ReadBackwards
by eserte (Deacon) on Jun 03, 2004 at 16:50 UTC
    Run the script through the perl debugger and look at the value of $read_size. Or better: set a watchpoint to see where the value of $read_size changed to be negative.
Re: Problem with File::ReadBackwards
by duff (Parson) on Jun 03, 2004 at 16:10 UTC

    Find out why your script all of a sudden started producing negative values for $read_size. Or post the rest of the script somewhere where people can look at it and comment.

Re: Problem with File::ReadBackwards
by McMahon (Chaplain) on Jun 03, 2004 at 16:38 UTC
    What are the values of $handle, $read_buf, and $read_size when your script quits? How are those values set?
Re: Problem with File::ReadBackwards
by El Linko (Beadle) on Jun 03, 2004 at 20:14 UTC
    Is this happening with just one file or all files you try it with?
    use Fcntl "SEEK_END"; print SEEK_END . "\n"; print 1 << 13; print "\n";'
    The above code should print 2 and 8192,does it?
Re: Problem with File::ReadBackwards
by Dru (Hermit) on Jun 07, 2004 at 14:42 UTC
    Thanks for the replies I should tested it against another file before posting here. It works fine on a different file, so it must not be File::Readbackwards. I'll have too do some digging to find out what's causing this.
      Another idea: is this a very large file? Then you maybe need large file and/or large integers support built in your perl.