Help for this page

Select Code to Download


  1. or download this
    my $testString = "          00008008 000000FF 00800000";
    $testString =~ s/\s+//g;
    ...
    my $maskResult = substr($bits, 1, 1) eq '1';
    
    printf "%s\n--> 2nd bit from left: %d\n", $bits, $maskResult;
    
  2. or download this
    my $testString = "          01008008 000000DF 00800000";
    my $mask       =           "42000000 00000020 00000000";
    ...
    $maskResult =~ tr/\0//d;
    
    printf "There were %s matching bits.\n", length($maskResult) ? "some":
    +"no";