Why pack 'V'?
substr( $v, $p / 8, 1 ) is a byte, why mask with 4 bytes?
In reply to Re^2: Efficient bit counting with a twist. by BrowserUk in thread Efficient bit counting with a twist. by BrowserUk