#!/usr/bin/perl -w
print '', "\n";
print "\n";
for (0 .. 9000) {
my $word = get_word();
print "<$word>\n";
if (rand(10) > 3) {
for (0 .. rand(5)) {
my $msg = get_words(30);
print "\t$msg\n";
}
}
print "$word>\n";
}
print "";
BEGIN {
my @words;
open(WORDS, "/usr/dict/words")
or open(WORDS, "/usr/share/dict/words")
or die "Can't open /usr/dict/words or /usr/share/dict/words: $!";
while () {
chomp;
push @words, $_ if /^\w+$/;
}
srand (time ^ $$);
# get a random word
sub get_word {
return lc $words[int(rand(scalar(@words)))];
}
# get $num random words, joined by $sep, defaulting to " "
sub get_words {
my ($num, $sep) = @_;
$sep = " " unless defined $sep and length $sep;
return join($sep, map { get_word() } (0 .. ((int(rand($num)))+1)));
}
}