in reply to sequence of positions to binary sequence

my @pos = (2,4,6,9) ; my $bits = '' ; foreach (@pos) { vec($bits, $_, 1) = 1 ; } ; ($bits = unpack('b*', $bits)) =~ s/0+$// ; my @bits = split(//, $bits) ; print "(", join(',', @bits), ")\n" ;
...when dealing with bit vectors vec is your friend, as are unpack/pack b/B and (occasionally) reverse.