The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

String::BitCount - count number of "1" bits in strings

SYNOPSIS

  use String::BitCount;

  # next line recommended for Perl versions 5.006 and newer.
  use bytes;

  # get the number of bits in $string.
  my $count = BitCount($string);

  # prints '334'; The number of bits in the codes
  # of 'a', 'b' and 'c' are '3', '3' and '4'.
  print showBitCount('abc'), "\n";

DESCRIPTION

BitCount LIST

Joins the elements of LIST into a single string and returns the the number of bits in this string. Only code points in the range 0x00 .. 0xFF are allowed.

showBitCount LIST

Copies the elements of LIST to a new list and converts the new elements to strings of digits showing the number of set bits in the original byte. In array context returns the new list. In scalar context joins the elements of the new list into a single string and returns the string.

NOTES

The arguments of this subroutines are restricted to strings of characters having code points in the range 0x00 .. 0xFF. If any string argument has code points greater than 0xFF (255) a "Wide character" warning will be issued.

AUTHOR

Winfried Koenig <w.koenig@acm.org>

SEE ALSO

perl(1)