[ale] Binary Grep

Fletch fletch at phydeaux.org
Wed Nov 17 19:10:38 EST 2004


>>>>> "Joe" == Joe Steele <joe at madewell.com> writes:


    Joe> Well, since I've already been labeled a spoil sport...  :)

Gah, yes it misses multiple matches per block.  I blame the mucus
currently clogging my throbbing sinuses for the past couple of days.

$ perl -le 'print "a" x 400, "\xff" x 16, "a" x 400, "\xff" x 16, "a" x 400, "\xff" x 16' > foo 
$ perl -lne 'BEGIN{$/=\1024}$o=($.-1)*1024-length$b;$b.=$_;print"hit byte ",$o+$-[0]while$b=~/\xff{16}/g;$b=substr($b,-15,15)' foo
hit byte 400
hit byte 816
hit byte 1232

[...]

    Joe> Notice also that I have cut down on the gratuitous use of
    Joe> needless white space without any loss of readability :)

Yup, you don't really need it in there and I tend not to really use it
on the command line.  If it was a real program this'd look much
different (with $offset and $buf rather than $o and $b, yadda yadda
yadda).

-- 
Fletch                | "If you find my answers frightening,       __`'/|
fletch at phydeaux.org   |  Vincent, you should cease askin'          \ o.O'
                      |  scary questions." -- Jules                =(___)=
                      |                                               U



More information about the Ale mailing list