in reply to Script critique requested
Unfortunately, this is alot easier.
First of all, you could use some loop starting with multiplying a variable by 2, like this:
my $bit = 256; for (1..8) { $bit /= 2; print $dec & $bit; }
Secondly, you can just use pack and unpack instead: print unpack ("B8", (pack "c",$dec)); Explanation: pack the number as a signed char value (0..255) in a byse sequence and unpack as 8 bits.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Script critique requested
by jhumphreys (Novice) on Oct 04, 2012 at 17:44 UTC |