The problem with this code is that it increments the count even if binary value = 01 01 10 01 i.e. bb = 10 and aa = 01 I want it to increment the count only if aa || bb || cc || dd is zero It would have been easier if I could have somehow split the 8 bit binary number into 2 bits each in the format of dd cc bb aa However I don't know how to do that. Will unpack help here? Anywayz would be greatful if someone can help me with this. At the end of the loop the counter should have value 101 and right now it reaches count 107. Thanks.------------------------------- for ($v = 0; $v < 128; $v++) { $bin_num = sprintf("%0b", $v); # This will give me the binary num +ber if ($v < 64) { $cnt++; # Because uptil value 63 "dd" is always going to be +zero } else { if ($bin_num =~ /00/) { print "\n Coming here if string 00 found for value $bin_nu +m \n"; $cnt++; } else { print "\n Coming here if string 00 NOT found for value $bi +n_num \n"; } } -------------------------------
In reply to binary string by alih110
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |