in reply to Re: How do I search this binary file?
in thread How do I search this binary file?

I don't understand your point. Why does double-scanning (and copying a megabyte) prevent "double matches"? Copying just the last 3 bytes (not 4!) to the beginning and then reading the next meg into the scalar after that would avoid the copy, and it can't match twice because the 4 bytes in the pattern are all different so matches can't overlap. Even without that restriction, the "junking" of previous found matches would take care of it.

  • Comment on Re: Re: How do I search this binary file?

Replies are listed 'Best First'.
Re: Re: Re: How do I search this binary file?
by tachyon (Chancellor) on Aug 20, 2002 at 22:42 UTC

    When you read from a disk you get a minimum of 512 bytes read (one sector) but in reality the disk reads and buffers a decent sized chunk (varies but ever wondered why disks have RAM?). Practical experimentation reveals an optimum read size (for a perl match type program) of 1-4MB as outlined in the RE:Performance Question link.

    OK 3 bytes is fine if all the bytes are different and there is no overlap - you did not specify.

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print