Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re^2: Searching in binary files

by crenz (Priest)
on Dec 14, 2005 at 18:25 UTC ( #516720=note: print w/ replies, xml ) Need Help??

in reply to Re: Searching in binary files
in thread Searching in binary files

Danke nach Frankfurt!

There are a few bugs in your code, though. I changed the if to a while loop and fixed a few other problems:

while ($str =~ /searchword/g) { my $loc = tell($fh) - length($str) + pos($str); print "Found a match starting after $loc.\n"; }

Update: That doesn't quite work either... it finds too many occurrences...

Comment on Re^2: Searching in binary files
Select or Download Code
Replies are listed 'Best First'.
Re^3: Searching in binary files
by Anonymous Monk on Mar 21, 2013 at 20:19 UTC
    while ($str =~ /$pattern/g) { my $loc = tell($fh) - length($str) + pos($str) - length($patte +rn); print "Found a match starting after $loc.\n"; }

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2015-11-25 15:08 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (679 votes), past polls