I am new to perl and I need some help with the bit manipulation in perl. This is what I want to do. I have a string $str = “453D” and It needs to be masked so that only lower 8 bits are set. Then for 3D I need to find all bits set. so
$i=0;
@bitsset;
$str = $str&0xFF;
for $i(0..7)
{
$str = ($str>>1);
if($str&1)
{
push(@bitset,$i);
}
}
I wrote this program like a C program. Can some one correct the syntax and logical errors please.
1 Answer