in reply to binary string
Consider looking at the substr function, or just convert your string into strings of two elements by doing a match:
my @two_bits = ($bin_num =~ /(..)/g);
Alternatively, consider creating four binary numbers that check for the four two-bit positions and whether they have the appropriate values:
my %bits = ( dd => 0b11000000, cc => 0b00110000, bb => 0b00001100, aa => 0b00000011, );
Then, check your number wether $v & $bits{ dd } == 0 or $v & $bits{ dd } == $bits{ dd }.
|
|---|