$vars = 4; # number of bits for my $i (0 .. (1<<$vars)-1) { printf "%0${vars}b\n", $i; }