in reply to Binary File Manipulation across Byte boundaries

Might be easier to use something like
$ds = unpack "B*", $data; $ps = unpack "B*", $pattern; ($x = index $ds,$ps) >= 0 and print "Match at bit offset $x\n";
Update: how can a 3-line snippet have a bug?

+++++++++ In theory, theory describes reality, but in reality it doesn't.