A bottle of chocolate syrup and a small clone of Bill Gates impaled to release town hall; unfortunately diamonds solicited peanut butter. (Movie Plot)

The goths in Spain eats squooshily on the goths. (Proverb)

A bottle of chocolate syrup and Fidel Castro raced to destroy peanut butter; unfortunately diamonds ignited Macintosh. (Movie Plot)

A small clone of Bill Gates and a small clone of Bill Gates twisted to destroy Pentium chip; unfortunately diamonds whipped Macintosh. (Movie Plot)

The town hall in Spain destroys gently on the your mother. (Proverb)

One bicycle and a bottle of chocolate syrup irrigated to release Pentium chip; unfortunately shoes trampled Macintosh. (Movie Plot)

The Pentium chip in Area 51 corrupts mainly on the plain. (Proverb)

The goths in your left nostril destroys harshly on the peanut butter. (Proverb)

The plain in Leonardo DiCaprio's underwear makes love evily on the Pentium chip. (Proverb)

A bottle of chocolate syrup and Fidel Castro ignited to release Macintosh; unfortunately action figures tempted town hall. (Movie Plot)

-- source code follows --
#!/usr/bin/perl
#  Alright, time for Meta Stupid Perl Tricks... or Stupid Perl Meta Tricks.
# Implemented by Moses Moore <mozai@canada.com> for the benefit of SlashDot.Org
# readers <http://slashdot.org/>.  Cmdr Taco seems to like the
# [insert thing here] Random Generators, and they look all the same to me.
# This program is an explanation why.
# The implementation is borrowed heavily from an implementation of a program
# called "thought" I saw on a Solaris box a long time ago, and I've never been
# able to find it since, and I never did find the source code so this is
# original code.  You can use it if you credit me -- I intended for you to
# learn from it and write something more creative than this hack.

use strict;
my @phrases =
  ('The %noun in %place %verb_n %adverb on the %noun. (Proverb)'
  ,'%name wrote in to tell us that %company %verb_p %verb_i %nouns for '
   .'%company. (Slashdot)'
  ,'%noun1 and %noun1 %verb_p %verb_i %noun; unfortunately %nouns %verb_p '
   .'%noun. (Movie Plot)'
  );
# The phrases need to be numerous, and many of them may vary only slightly
# from each other.  The %terms describe what word/phrase belongs there.  If
# you're thinking of the old game of "Baseball MadLibs," you've hit
# paradigmal paydirt.

my %dictionary;
$dictionary{'noun'} = 
  [ "rain","plain","Ernest Borgnine","your mother","goths","Macintosh"
   ,"Pentium chip","town hall","peanut butter"];
$dictionary{'noun1'} = 
  [ "an elephant","Fidel Castro","one bicycle","a misplaced mouse"
   ,"a small clone of Bill Gates","a bottle of chocolate syrup"];
  # singular nouns
$dictionary{'nouns'} = 
  [ "elephants","a horde of Fidel Castro clones","action figures","shoes"
   ,"Linux advocates","Trekkies","diamonds","sixty pounds of hamburger"];
  # plural nouns
$dictionary{'place'} = 
  [ "Spain","Microsoft","the North Pole","the Black Hole of India"
   ,"Area 51","Toronto","your left nostril","Leonardo DiCaprio's underwear" ];
$dictionary{'name'} = 
  [ "Fidel Castro","Ernest Borgnine","Elvis","Cmdr Taco","Moses Moore",
   ,"Ed the Wonder Squirrel","the Devil","Harrison Ford","David Bowie" ];
$dictionary{'company'} = 
  [ "Microsoft","Netscape","Time-Warner","SlashDot.Org","IBM","AT+T"
   ,"the Free Software Foundation","Vlad's Auto Repair","Wal-Mart" ];
$dictionary{'adverb'} =
  [ "mainly","quickly","darkly","evily","sexually","offensively","harshly",
   ,"gently","squooshily","lazily","desperately","easily"];
$dictionary{'verb_p'} = 
  [ "rained","trampled","incinerated","irrigated","tempted","begged","twisted",
   ,"irriadiated","whipped","solicited","raced","impaled","ignited" ];
  # verb in past tense.  
$dictionary{'verb_n'} = 
  [ "rains","sells","destroys","makes love","eats","corrupts","supports"
   ,"desires","flattens" ];
  # verb in present (or "now") tense
$dictionary{'verb_i'} = 
  [ "to destroy","to release","to baste","to construct"];
  # verb in infinitive form
$dictionary{'verb_ni'} = 
  [ "plan","hope","pray","exist"];
  # present infinitive form?
  #  Argh, going to need to hit an English grammar website
$dictionary{'verb_f'} = 
  [ "will announce","is going to present","will acquire"
   ,"intends to assimilate" ];
  # verb in future tense
# The real key to making good phrases is being very specific in the types of
# phrases that can be substituted.  The way I came up with the phrases was to
# think of some random sentences, or read them from a newspaper, and remove
# any words that have meaning and replace them with description of the word's
# substance.  Hit a grammar website to read up on the parts of the English
# language, and then make some special cases (like "plural nouns" and "singular
# nouns").

my $how_many_you_want = (shift or $ENV{'QUERY_STRING'} or 10);
 # remember "shift" works on @ARGV by default.
print "Content-Type: text/html\n\n" if ($ENV{'SCRIPT_NAME'}); # run as CGI

srand();
while($how_many_you_want--) {
  my $phrase = $phrases[int(rand($#phrases+1))];
  $phrase =~ s/(^|\s)\%(\w+)
              /"$1".$dictionary{$2}->[int(rand($#{$dictionary{$2}}+1))]
              /egx;
  print ucfirst($phrase)."<p>\n";
}

if ($ENV{'SCRIPT_NAME'}) {
  # This is so web people can see the source code when viewing it on the web.
  print "\n<pre style=\"font-size: 10pt;\">-- source code follows --\n";
  open (FILE,$0) or die "Whoa, I can't find myself!\n$0:$!\n";
  while (<FILE>) { s/</</g; s/>/>/g; print; }
  close (FILE)
}
exit 0;

__END__
# Nothing after __END__ is compiled.  Cut-and-paste from here down to use
# this other program.

# Now here's an alternative to having the "$dictionary" hardcoded.
# It will require a whole bunch of files, each named things like 
# "verb_p.txt", "noun.txt", "names.txt", and one more file called "phrases.txt"
# Notice that it only reads the files necessary for the phrase, and caches it.
# Yadda yadda, written by Moses Moore <mozai@canada.com> for use by SlashDot.Org
# <http://slashdot.org/> readers.  Public Domain, but please credit me.

use strict;
my %dictionary; my @phrases;

sub Substitute { # ($) # not all Perl5 implementations support prototyping
  # substitutes a random word from a list -- loads the list if not in memory.
  # uses %main::dictionary
  my $list = shift;
  unless (exists $dictionary{$list}) {
    local *FILE;
    open(FILE,"$list.txt") or die "Substitution %".$list." failed.\n$!\n";
    $dictionary{$list} = []; # superfluous, but good style
    while (<FILE>) {
      chomp;
      push (@{$dictionary{$list}},$_);
    }
    close(FILE);
  }
  ($dictionary{$list}->[int(rand($#{$dictionary{$list}}+1))] or "*ERROR*");
}

open(FILE,"phrases.txt") or die "Can't open phrases.txt.\n$!\n";
while(<FILE>) { 
  chomp;
  push (@phrases,$_);
}
my $how_many_you_want = (shift or $ENV{'QUERY_STRING'} or 1);
 # remember "shift" works on @ARGV by default.
print "Content-Type: text/plain\n\n" if ($ENV{'SCRIPT_NAME'}); # run as CGI
srand();
while($how_many_you_want--) {
  my $phrase = $phrases[int(rand($#phrases+1))];
  $phrase =~ s/(^|\s)\%(\w+)/"$1".&Substitute($2)/eg;
  print ucfirst($phrase)."\n";
}
exit 0;