withmy $p = join '|', map { "$pre[$_]\\0{@{[($N-$_)>>3]}}$suf[($N-$_)&0x7] +" } 0..7;
By construction, only one will match and $#- will tell you which one. We place the leftparen so that the group always starts at the first byte that's beginning with a zero bit. Then you just have to subtract the number of zero bits at the end of the byte that $pre[$_] is matching, but that's just $#- - 1. So the answer ismy $p = join '|', map { "$pre[$_](\\0{@{[($N-$_)>>3]}}$suf[($N-$_)&0x7 +])" } 0..7;
Still needs a bit more work to handle the $N < 8 case.$-[$#-]*8 - $#- + 1
In reply to Re^5: Locating a specified number of contiguous 0 bits within a large bitstring efficiently.
by wrog
in thread Locating a specified number of contiguous 0 bits within a large bitstring efficiently.
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |