in reply to An array of boolean values in a bitfield
If you want a fast bit counter use unpack:
sub unpack_count { my ( $bits ) = @_; my $count = unpack '%32b*', $bits; return $count; } [download]