$ perl5.6.2 -we'$x = "\x01\x02"; $binary = sprintf "%0v8b", $x; > $binary =~ tr/.//d; print $binary' 0000000100000010