#!/usr/bin/perl -l

#                                                          ppg256-4.pl
# Perl Poetry Generator in 256 Characters, Number 4
# 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. The version of the 
# program that drives an LED sign is 256 characters long:
#
# perl -e 'sub c{$_=pop;$_[rand split]}sub w{c("b br d f fl l m p s tr w").c"ad ag ap at ay ip on ot ow"}{$|=print"\0\0\0\0\0\1Z00\2AA\33 b".c("be de mis re pre ").w." ".c("a on the that")." ".w.w.", ".c("boss bro buddy dogg dude guy man pal vato")."\4";sleep 4;redo}' > /dev/alpha
#
# The terminal version, which does not have to include control
# characters for the sign, is shorter:
#
# perl -le 'sub c{$_=pop;$_[rand split]}sub w{c("b br d f fl l m p s tr w").c"ad ag ap at ay ip on ot ow"}{print "\n".c("be de mis re pre ").w." ".c("a on the that")." ".w.w.", ".c("boss bro buddy dogg dude guy man pal vato");sleep 4;redo}
#
# The only changes that have been made from this version 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-4.pl

sub c
  {
    $_ = pop;
    $_[rand split]
  }
sub w
  {
    c("b br d f fl l m p s tr w").c"ad ag ap at ay ip on ot ow"
  }
{
  print "\n".c("be de mis re pre ").w." ".c("a on the that")." ".
    w.w.", ".c("boss bro buddy dogg dude guy man pal vato");
  sleep 4;
  redo
}
