my @bits; $bits[$_] = 1 for @pos; for (0..($#bits-1)) { $bits[$_]=0 unless defined($bits[$_]); }