in reply to Printing, analyzing binary
You can also use the new vector modifier 'v' to avoid the ord (or to output multiple bytes worth at once):
If you want just an uninterrupted stream of digits for the latter, remove the .'s afterward:$ perl5.6.2 -we'$x = "\x01"; printf "%0v8b", $x' 00000001 $ perl5.6.2 -we'$x = "\x01\x02"; printf "%0v8b", $x' 00000001.00000010
$ perl5.6.2 -we'$x = "\x01\x02"; $binary = sprintf "%0v8b", $x; > $binary =~ tr/.//d; print $binary' 0000000100000010
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Printing, analyzing binary
by perlfan (Parson) on Apr 26, 2004 at 18:24 UTC |