perl -e' @pos=qw(2 4 6 9); $max=0; for (0..(@pos -1)){ $bin[$pos[$_]]=1; $max=$pos[$_] if $max<$pos[$_]; } for (0..$max){ $bin[$_]=0 unless $bin[$_]; } print "@bin\n";'