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


in reply to bit string

Binary printf formats aren't supported in earlier versions. From v5.6.0 perldoc perldelta:

"Binary numbers supported

 Binary numbers are now supported as literals, in s?printf formats, and `oct()':

     $answer = 0b101010;
     printf "The answer is: %b\n", oct("0b101010");"

Update: forgot to put in the meat.
As a string:

$ perl -e '$c = 12;print reverse map {vec $c,$_,1} 0..8*length($c)-1; +' 0011001000110001

As a number:

$ perl -e '$c = 12;print reverse map {$c&1<<$_?1:0} 0..8;' 000001100

After Compline,
Zaxo