Infinite monkey theorem

From Uncyclopedia test II
Jump to navigation Jump to search
#!/usr/local/bin/perl
#
# I didn't feel like writing more articles, so I wrote this Perl script to generate all possible
# texts up to a certain length. Run this and Illogicopedia's done, pretty much.

use constant LENGTH => 1000; #Number of characters

gen("", LENGTH);

sub gen {
	my ($text, $lenleft) = @_;
	my $newtext;

	return if $lenleft <= 0;

	$lenleft--;

	for (my $i=32;$i<=122;$i++) {
		next if $i == 45;
		$newtext = $text . chr($i);
		print "$newtext\n\n----\n\n";
		gen($newtext, $lenleft);
	}
}