Per me si va nella citt dolente
Per me si va nell'eterno dolore

#! /usr/bin/perl -w
sub o{1&9|9&0}sub fn{shift}sub mc2{6..9}marine($e=q
q[m|bi]q);sub h{&o<<o}@
	e=mc2;
	sub limination{$CO2=
	&fn;ord
($CO2)/h}$qq=qq;
e[o|h];;$qq=~s/
//m;{marine(my$qq=qq){${*qq}\{));
sub qq{$
	E=&limination
+&limination;chr$E}sub
	yellow{alert
(qq)${qq}${e}),'-t',map{($q=(m]^\s+($qq\w*)\s+(\u$qq)])[h>>h])
eq(qq)${qq}faq))?map{qq.$q..$_}map{$_||q||}o>>o..eval
qq:\$${*qq}::qq}$q}}grep(m{^\s+?${\$qq}\w*\s+\u${qq}},qx)
$qq$e -t $qq)));}}
	yellow;sub marine
{$_[o>>o]=~s((.)(.))(&qq($1,$2))ge};sub alert{system@_}
__END__

Lasciate ogni speranza, voi ch'entrate! [0]

This program parses the `perl' perldoc page, builds a list of the core
perldoc pages, and presents them all in the listed, suggested order.
For those who can't afford the Camel or Llama (and who have a week or
so of free time), this script offers a reasonable overview of the
language, from basic concepts to the twisted, eldritch, unwholesome
secrets of the black and evil heart of /usr/bin/perl.  It is assumed
that the user can read; thus, the program will not be too useful to
those whose verbal and textual recognition skills have been scarred by
years of exposure to Perl.

The program is perhaps best understood if formatted reasonably, and
analysed line-by-line:

sub o {	1&9|9&0 }
  This sub returns the number 1.  Unless one remembers that in C and
  Perl, & has higher precedence than |, this sub appears to return 0.
  The reasoning behind the name will become apparent later.

sub fn { shift }
  This sub appears to do nothing more than return its first parameter.
  However, it is called as &fn (see sub limination below).  This
  causes it to act on the @_ of its caller; thus, &fn behaves in
  exactly the same way as shift.

sub mc2 { 6..9 }
  Returns the list (6, 7, 8, 9).  Not very obfuscated.

marine($e=q q[m|bi]q);
  Assigns '[m|bi]' to $e, then calls marine on it (see below).  Yes,
  appropriate positioning of whitespace allows word characters to be
  used as delimiters for q//, s///, and other such abominations.

sub h {&o << o}
  The sub h returns 2.  Were that ampersand (or appropriate
  parentheses) not present, perl would treat <<o as a heredoc,
  which would not be a good thing.

@e=mc2;
  (Yes, you can use whitespace to split the type punctuation from the
  rest of the variable name.)  Assigns (6, 7, 8, 9) (see above) to @e.

sub limination {
	$CO2=&fn;
	ord($CO2)/h
}
  Returns the ASCII value of the first argument, divided by two.  &fn
  means the same as shift; see above for why.

$qq = qq;
e[o|h];
;$qq=~s/
//m;
  Sets $qq equal to "\ne[o|h]", then removes the "\n".  The resulting
  string ("e[o|h]") will be used later in two different places, for two
  very different purposes.

{ marine (my $qq = qq){${*qq}\{));
  The initial { simply begins a block.  This statement creates a local
  variable $qq, and assigns to it the string "{${*qq}\{" eq "{e[o|h]{".
  It then calls marine (see below) on my $qq.  Note the many forms of
  obfuscation here:
   * Shadowing of a global by a `my' variable.
   * Accessing a shadowed global through the symbol-table entry for
     that variable.
   * Use of right parenthesis as the qq// delimiter.
   * Use of ${*qq} to store most of an encoded string, *and* (later
     on, in sub yellow) as most of a string to be eval'd.

sub qq {
	$E = &limination + &limination;
	chr $E
}
  This sub (with the same name as a variable and an operator!) takes
  the arithmetic average of the ordinal values of the first two
  arguments, converts back to ASCII, and returns the result.

  ``But wait!'', you say.  ``I don't see a shift or a $_[2] here; how
  do you refer to the second argument?''  Because &subname gives a
  called sub the same @_ as its parent, any modifications made to @_
  in sub limination affect @_ in sub qq.  As it turns out, sub
  limination (see above) calls &fn, which calls shift.  The upshot of
  this is that the first &limination refers to the first argument, and
  the second refers to the second argument.


The next snippet is a bit tricky, as it is one huge LISPy function:


sub yellow {                                                    # 0
  alert (qq)${qq}${e}), '-t',                                   # 1
     map { ($q=(m]^\s+($qq\w*)\s+(\u$qq)])[h>>h]) eq            # 2
            (qq)${qq}faq))                                      # 3
      ? map {qq.$q..$_}                                         # 4
        map {$_ || q||}                                         # 5
          o>>o..eval qq:\$${*qq}:                               # 6
      : qq}$q}                                                  # 7
     } grep (m{^\s+?${\$qq}\w*\s+\u${qq}},                      # 8
             qx)$qq$e -t $qq))                                  # 9
  );                                                            # A
}                                                               # B

  GAH!  RELEASE ME FROM THIS EVIL!  Perhaps tracing backwards through
  the code would help.

   * Line 9: here we evaluate `$qq$e -t $qq` (again using closing
     parenthesis for things it was not meant to do).  By the time we
     get here, $qq (referring to the my variable) is 'perl', and $e
     is 'doc'.  See sub marine, below, for the reason.

     Since this line is evaluated in list context, we get a list of
     the lines from `perldoc -t perl`.

   * Line 8: grep this list for /^\s+?perl\w*\s+Perl/ .  ${\$qq} is
     just extra repetitive redundant redundancy, and still refers to
     my $qq, not the global of the same name.

     The regexp matches lines of the form:
          perlfoo     Perl support for Fantastic Object Orientation.

     Which (in the `perl' perldoc page) are references to other
     perldoc pages.

   * Lines 2-7: apply a map to this list.  For each element of the
     list returned from grep:
      * First, assign to $q the value (/^\s+(perl\w*)\s+(Perl)/)[h>>h].
        h>>h == 0, so $q gets whatever matched perl\w* .  This is the
        name of the appropriate perldoc page.
      * Does that string equal 'perlfaq'?
         If so, this element puts the result of lines 4-6 into the
          result of the map
         Otherwise, this element puts itself into the result of the map.
      * Lines 4-6:
         * Line 6: first, constuct the list o>>o..eval "\$${*qq}".
           o>>o is 0.  "\$${*qq}" interpolates to "@e[o|h]"; this
           evaluates to 9.  Thus, we have the list (0..9).
         * Line 5: create a copy of this list, with 0 replaced by ''.
           This relies on Perl's value-preserving || operator.
         * Line 4: make a copy of *that* list, with $q (== "perlfaq")
           prepended
        These lines end up generating the list ("perlfaq", "perlfaq1",
        ..., "perlfaq9"), which gets put into the list returned from
        the map in line 2.

   * Line 1: call sub alert with the arguments "perldoc", '-t', and
     the list returned from the map on line 2.  alert calls system
     (see below), so we end up executing perldoc -t foo, where foo is
     the list of perldoc pages referenced in the `perl' page.

yellow;
  Execute that bizarre tangle of junk that just took 1-3 pages
  (depending on your page size) to describe.

sub marine {
	$_[o>>o] =~ s((.)(.))(&qq($1,$2))ge
};
  o>>o == 0, so $_[o>>o] refers to the first argument.  Decode that
  first argument by replacing each pair of characters with their ASCII
  average (see sub qq, above).

sub alert { system @_ }
  A synonym for system.


This code has been tested under Perl 5.002 and 5.004_04.  On the
latter, it even works with -w (5.002 generates some warnings about
ambiguous constructs).

In order to save memory (and thus be less likely to fail if being
judged to the minimum requirements), this program passes perldoc the
'-t' option.  If you have enough free memory, and you don't mind a
rather long wait, add:
  ($program = <<'EOP') =~ s/,'-t'//m; eval $program;
to the beginning of the program, and
  EOP
to the end.

If your version of perl does not provide the `perldoc' program, or if
perldoc -t doesn't print plaintext to stdout, complain to the
maintainer of that port.

As an added bonus, the indented lines form something of a poem---a
comment on the inherent absurdity and self-destructiveness of using
great scientific achievements (like nuclear physics, or Perl) as
instruments of destruction, brainwashing, and confusion.  I call the
work `Nuke Me Hard':

  e=mc^2
  sublimination of CO2
  fnord
  Elimination
  yellow alert
  yellow submarine

Or something like that.


``We separate him, together with his accomplices and abettors, from
the precious body and code of the Program and from the society of all
Programmers; we exclude him from our holy mother Perl in Real Life and
on the 'Net; we declare him excommunicate and anathema; we judge him
damned, with the creators of INTERCAL and MVS and all the reprobate,
to eternal COBOL until he shall recover himself from the toils of the
obfuscator and return to amendment and to penitence.''

So be it![1]

__DATA__

\0 `entrate' is a registered trademark of Dante Labs, Inc., makers
   of the Inferno operating system.

\1 Portions copyright 1998 the Roman Catholic Church; despite rumours
   to the contrary, *not* a subsidiary of Microsoft Corporation.
