in reply to sequence of positions to binary sequence

This feels like more of a C task than a perl task, so here's an answer in C-like perl...

my @pos = (2,4,6,9); my $bin = 0; for (my $i = 0; $i < scalar @pos; $i++) { $bin |= 1 << $pos[$i]; } # Printing out the result is left as a follow-on exercise...

--
use JAPH;
print JAPH::asString();