/usr/src/perl/pod/perlfaq4/How_do_I_convert_bits_into_ints_.pod

How do I convert bits into ints?

To turn a binary string like '10110110' into its decimal equivalent, use the pack function (documented in pack):

    $decimal = pack('B8', '10110110');

Here's an example of going the other way:

    $binary_string = join('', unpack('B*', "\x29"));