http://www.perlmonks.org?node_id=1020203

vr has asked for the wisdom of the Perl Monks concerning the following question:

I'm confused about code sample from here:

How do I manipulate arrays of bits?

They say:

...given a vector in $vec , you can get those bits into your @ints array:

and give following code as "fast general algorithm"

use integer; my $bits = unpack "b*", $vec; push @ints, 0 if $bits =~ s/^(\d)// && $1; push @ints, pos $bits while($bits =~ /1/g);

What are they trying to do with two lines starting with push operators? Don't they want to get a list "e.g. ( 1, 0, 0, 1, 1, 0 ... )" as stated in the beginning of that section, i.e. do reverse conversion? They can't do it with this code, do they?