Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Searching in binary files

by GrandFather (Saint)
on Dec 15, 2005 at 02:54 UTC ( [id://516836]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-04-24 15:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found