#print all combinations of 6 ones and 12 zeros for( 0b000000000000111111..0b111111000000000000 ) { my $x = sprintf("%018b",$_); next unless $x =~ /^0*10*10*10*10*10*10*$/; printf "$x\n",$_; }