Hi all,

I wanted to know how to parse a 8bit binary data bitwise?

I have my input in hex and i convert it into binary form using the following
logic:

%h2b = (0 => "0000", 1 => "0001", 2 => "0010", 3 => "0011",
4 => "0100", 5 => "0101", 6 => "0110", 7 => "0111",
8 => "1000", 9 => "1001", a => "1010", b => "1011",
c => "1100", d => "1101", e => "1110", f => "1111",
);

$hex = "43";
($binary = $hex) =~ s/(.)/$h2b{lc $1}/g;
print $binary, "\n";

Now the output for the above prg is

01000011

Now i have to display this binary data as shown below:

0=> abc
100=> def
0011=> lmn

How to go about this?

Reply via email to