in reply to all binary combinations

my $length = 3; for (0..2**$length-1) { printf("%0${length}b\n", $_); }

As a function:

sub bits { my ($length) = @_; return map sprintf("%0${length}b\n", $_), 0..2**$length-1; }

How long are you talking about?

Length 10 generates ~1,000,000 results
Length 20 generates ~1,000,000,000 results
Length 30 generates ~1,000,000,000,000 results

Update: Fixed placement of curlies.

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.