$ds = unpack "B*", $data; $ps = unpack "B*", $pattern; ($x = index $ds,$ps) >= 0 and print "Match at bit offset $x\n";