http://www.perlmonks.org?node_id=11107850


in reply to bit array comparison

The problem is that unpack "b*" takes a string of bytes.

And so does unpack "B*", what you'd use to get the bits in the same order as sprintf "%b".

$ perl -e'CORE::say unpack "B*", pack "L>", 3' 00000000000000000000000000000011

Tip: you should use | rather than + to set a bit (in case it's already set).

$b |= 1 << 2;