$vec = pack 'V', int( 2**32* rand() );; print $bits;; 011000001111110110010000101101 @ints = (); { use integer; push @ints, 0 if $bits =~ s/^(\d)// && $1; push @ints, pos $bits while $bits =~ /1/g; };; print @ints;; 1 2 8 9 10 11 12 13 15 16 19 24 26 27 29