in reply to Searching in binary files

What do you actually want to do? Check that the string exists? Count the number of occurences? Find a string that matches some pattern? Find a prefix string and extract some trailing text?

A neat way to perform some of those searches is:

local $/ = "the string to match"; while (<fileHandle>) { #do stuff with the "line" in $_ #chomp will remove "the string to match"; }

DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: Searching in binary files
by BrowserUk (Patriarch) on Dec 15, 2005 at 05:56 UTC

    That works well until the one occurance of the string is close to the end of your n GB file.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.