zyxwvutsrqponmlkjihgfedcba

nickm.com > poems | interactive fiction & e-lit

ppg256-2

Instructions and Poetry Generator Program

ppg256-2 is a very small computer program (256 characters long) that generates poems without recourse to a dictionary or any other external resource. It is distributed as text which can be typed on the command line in about four minutes or can be copied and pasted.

ppg256-2 is a Perl program and is easy to run from the command line on Mac OS X and Linux, which have Perl built in. The standard configurations of other platforms (including Solaris and FreeBSD) also include Perl. Unfortunately, Windows does not. Perl will run on Windows, but running it and ppg256-2 requires the installation of some additional free software: Cygwin first, then Perl for Cygwin. It is rather elaborate and time-consuming to install these programs, so Mac OS X or Linux are strongly suggested for running ppg256-2. ActivePerl, the other major Perl distribution for Windows, will not work with the command-line version of ppg256-2 because it uses the Windows command line. It is necessary to use a Cygwin shell when running the command-line version under Windows.

Alternatively, place ppg256-2.pl in the current directory and type "perl -l ppg256-2.pl" under Windows, with either version of Perl installed, to run the generator.

  1. Open a terminal window.

    Mac OS X: In the Applications folder, open the Utilities folder and run Terminal.

    Linux: The method of opening a window depends on the desktop environment. When using Ubuntu or another distribution that uses the same desktop environment, select Applications > Accessories > Terminal in the menu bar.

  2. Carefully copy the following text and paste it in the terminal window.

    perl -le 'sub p{split/,/,pop;$_[rand@_]}{$_=p("sw,-aw,&w,saw".", "x$l);s//p("aw,w")/e;s// /g;$_="\n\nthe s\n"if!$l;s/s/ws/;s/a/p("a,the,to,of")/e;s/w/p("b,ch,f,gr,k,p,sh,s,sk,sp,tw")."i".p("ll,n,t")/eg;s/(b|p|f)i/$1.p("a,i")/e;print;$l=0if$l++>6+rand 9;sleep 1;redo}'

    This text can also be typed into the terminal, allowing for easy distribution of ppg256-2 on a printout.

  3. Multiple terminal windows may be opened at once and ppg256-2 can be run in all of these.

  4. If it seems appealing, study the program, learning more about Perl to whatever extent this is necessary. Modify ppg256-2 to see how it works, initially, for instance, by changing the strings "b,ch,f,gr,k,p,sh,s,sk,sp,tw" "i" and "ll,n,t" so that they contain different word fragments for recombination. Write other small poetry generators to better understand and explore poetry, English (or another language), and computation.

ppg256 series page