Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: Perl program to search files

by vr (Deacon)
on Dec 26, 2018 at 12:12 UTC ( #1227708=note: print w/replies, xml ) Need Help??


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 (Chancellor) on Dec 26, 2018 at 12:47 UTC
    But he is trying to slide

    Ah, you are correct, thank you!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1227708]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2019-11-17 10:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (86 votes). Check out past polls.

    Notices?