#!/usr/bin/perl -l

#                                                          ppg256-3.pl
# Perl Poetry Generator in 256 Characters, Number 3
# Nick Montfort nickm@nickm.com
#====================================================================#
#
# This is a reformatted and commented version of a Perl program that 
# will run on Mac and Linux on the command line and which is 256 
# characters long:
#
# perl -le 'sub p{(unpack"(A3)*",pop)[rand 18]}sub w{p("apebotboyelfgodmannunorcgunhateel"x2)}sub n{p("theone"x8)._.p("bigdimdunfathiplitredwanwax")._.w.w."\n"}{print"\n".n."and\n".n.p("cutgothitjammetputransettop"x2)._.p("herhimin it offon outup us "x2);sleep 4;redo}'
#
# The only changes that have been made are the addition of spaces,
# newlines, and a few comments.
#
# On Windows, install ActivePerl to be able to run this program.
# To run, change to the directory where this file is located and type
# at the command prompt:
#
# perl -l ppg256-3.pl

sub p # Return a random three-character string from 18 packed elements
  {
    (unpack"(A3)*",pop)[rand 18]
  }
sub w # Return a three-letter noun
  {
    p("apebotboyelfgodmannunorcgunhateel"x2)
  }
sub n # Return a line/noun phrase with optional article and adjective
  {
    p("theone"x8)._.p("bigdimdunfathiplitredwanwax")._.w.w."\n"
  }
{ # Main loop
  print"\n".n."and\n".n.p("cutgothitjammetputransettop"x2)._.
    p("herhimin it offon outup us "x2);
  sleep 4;
  redo
}
