in reply to Brute force perl
See all valid Perl code ("use strict" is in force, else the results are less interesting) consisting of 3 typical characters with optional whitespace:
use strict; use Algorithm::Loops 'NestedLoops'; my @chars= map chr($_), ord(' ') .. ord('~'); my @spaces= ( "", "\n", shift @chars ); my $iter= NestedLoops( [ ( \@chars, \@spaces ) x 2, \@chars, ], { OnlyWhen => sub { @_ % 2 }, }, ); sub dump { 1; } sub exit { 1; } $SIG{__WARN__}= sub { 1; }; close STDIN; my @code; while( @code= $iter->() ) { my $code= join '', @code; if( eval "$code; 1" ) { print "($code)\n"; } }
It is trivial to expand this to look at larger code strings... but the results are less interesting, again. :)
- tye
|
|---|