http://qs321.pair.com?node_id=1227708


in reply to Re: Perl program to search files
in thread Perl program to search files

Minor note:

A typical solution to this kind of problem would be to implement a sliding window

But he is trying to slide:

$START += $BUFF_SIZE - length($FIND);

Unfortunately, it seems that his 4th argument to read is understood as "offset into file", while, of course, it is "offset into buffer". If this

read $F, $BUFFER, $BUFF_SIZE, $START;

is replaced with

seek $F, $START, 0; read $F, $BUFFER, $BUFF_SIZE;

then his sliding window works.

Replies are listed 'Best First'.
Re^3: Perl program to search files
by haukex (Archbishop) on Dec 26, 2018 at 12:47 UTC
    But he is trying to slide

    Ah, you are correct, thank you!