Haiku in Perl

Larry Wall, l'inventore del linguaggio Perl, ha scritto ovviamente molto codice sorgente, vincendo ben due edizione del IOCCC. Uno dei pezzi di codice meno famosi, tra quelli scritti da lui, è probabilmente questo:

	print STDOUT q
	Just another Perl hacker,
	unless $spring
	# Larry Wall
	# lwall@jpl-devvax.jpl.nasa.gov

Si tratta di programma Perl valido (nel senso che non ci sono errori sintattici) ma anche un haiku corretto.L'haiku è una forma tradizionale di poesia giapponese, nata nel XVII secolo e composta da soli 3 versi di 5, 7 e 5 sillabe.

Erano anni in cui i riferimenti alla cultura giapponese erano piuttosto diffusi. Ad esempio, la forma "Zen of" era considerata sinonimo di "il meglio del meglio di".

JAPH (Just Another Perl Hacker) è anche un topos, un luogo poetico, un meme tipico del Perl. Un JAPH è un codice che scrive esattamente se stesso, ed è stato usato come firma nei messaggi. Anche in questo caso, come per i IOCCC, può essere una forma di virtuosismo, in cui non si capisce a prima vista come fa quel codice a scrivere quella frase. Quello che segue è un JAPH che non usa segni di interpunzione:

   not exp log srand xor s qq qx xor
   s x x length uc ord and print chr
   ord for qw q join use sub tied qx
   xor eval xor print qq q q xor int
   eval lc q m cos and print chr ord
   for qw y abs ne open tied hex exp
   ref y m xor scalar srand print qq
   q q xor int eval lc qq y sqrt cos
   and print chr ord for qw x printf
   each return local x y or print qq
   s s and eval q s undef or oct xor
   time xor ref print chr int ord lc
   foreach qw y hex alarm chdir kill
   exec return y s gt sin sort split
Una galleria di JAPH può essere esplorata qui.

Sharon Hopkins è forse la più famosa autrice di Haiku in Perl, a partire dal suo contributo del 1992 Camels and Needles: Computer Poetry Meets the Perl Programming Language

In quel testo analizza l'haiku di Wall così:

   In this poem, the q operator causes the next character (in this case a newline)
   to be taken as a single quote, with the next occurrence of that delimiter taken
   as the closing quote. Thus, the single-quoted line ’Just another Perl hacker,’
   is printed to STDOUT. In Perl, the "unless $spring" line is mostly filler, since
   $spring is undefined. In poetical terms, however, "$spring" is very important:
   haiku poetry is supposed to specify (directly or indirectly) the season of the year.
   As for the q operator, that reads in English as the word "queue", which makes
   perfect sense in the context of the poem
Hopkins chiarisce anche che $ va letto "dollar" e che "q" va letto "queue" perché la poesia sia un haiku corretto con il giusto numero di sillabe.

Dopo aver abbozzato nell'articolo una poetica dei perl haiku ("There are basically two types of Perl poetry: those poems that produce output, and those that do not. The former, not surprisingly, are much harder to write.") Hopkins si dedica anche alla loro scrittura. Questo è uno dei suoi componimenti:

   #!/usr/bin/perl

  APPEAL:

  listen (please, please);

  open yourself, wide;
    join (you, me),
  connect (us,together),

  tell me.

  do something if distressed;

    @dawn, dance;
    @evening, sing;
    read (books,$poems,stories) until peaceful;
    study if able;

    write me if-you-please;

  sort your feelings, reset goals, seek (friends, family, anyone);

        do*not*die (like this)
        if sin abounds;

  keys (hidden), open (locks, doors), tell secrets;
  do not, I-beg-you, close them, yet.

                            accept (yourself, changes),
                            bind (grief, despair);

  require truth, goodness if-you-will, each moment;

  select (always), length(of-days)

  # listen (a perl poem)
  # Sharon Hopkins
  # rev. June 19, 1995

Prossimo pannello:  Apollo



Versione: 20/01/2022 - 22:53:02

Parole: 354

Pannelli

Codici                      
Hello World                 
99 bottles of beer          
Haiku                       
Apollo                      
Colossal Cave               
Zork                        
TAUmus                      
🔎