lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (01/05/90)
Just for the fun of it, here's a travesty in perl. It's based on the same idea, but it's not a translation. It's still a little rough in some ways, but it will trim article headers for you. Here's a paragraph of the new, revised perl manual (-: A subroutine may not make much sense to you. It's here at the end) and does certain optimizations with the package name is omitted, format "STDOUT" is defined. FORMLIST consists of a loop modifier, executes the second way hides the main point isn't whether the user typed -v or not. References to scalar variables, normal array values, and anything after it will not look for a script whether the lvalue EXPR has a real value or not. LIST operators have the newline is printed. The special field @* can be put anywhere a command to which output is to include subroutines from a subroutine but rather the name of the primary sequence of characters sent, or the right side of the following: Semicolons are required on ifs and whiles. Variables begin with '$', even when $* is 0. Default is 0, exits with 255. Equivalent examples: die "Can't open $foo: $!"; is better than verbose && print "Starting analysis\n" if $verbose; is better than verbose && print "Starting analysis\n"; since the language has more built-in functionality, it has to rely less upon external (and possibly untrustworthy) programs to accomplish its purposes. #!/bin/sh : make a subdirectory, cd to it, and run this through sh. echo 'If this kit is complete, "End of kit" will echo at the end' echo Extracting travesty sed >travesty.pl <<'!STUFFY!FUNK!' -e 's/X//' X#!/usr/bin/perl X Xwhile (<>) { X next if /^\./; X next if /^From / .. /^$/; X next if /^Path: / .. /^$/; X s/^\W+//; X push(@ary,split(' ')); X while ($#ary > 1) { X $a = $p; X $p = $n; X $w = shift(@ary); X $n = $num{$w}; X if ($n eq '') { X push(@word,$w); X $n = pack('S',$#word); X $num{$w} = $n; X } X $lookup{$a . $p} .= $n; X } X} X Xfor (;;) { X $n = $lookup{$a . $p}; X ($foo,$n) = each(lookup) if $n eq ''; X $n = substr($n,int(rand(length($n))) & 0177776,2); X $a = $p; X $p = $n; X ($w) = unpack('S',$n); X $w = $word[$w]; X $col += length($w) + 1; X if ($col >= 65) { X $col = 0; X print "\n"; X } X else { X print ' '; X } X print $w; X if ($w =~ /\.$/) { X if (rand() < .1) { X print "\n"; X $col = 80; X } X } X} !STUFFY!FUNK! echo "" echo "End of kit" : I do not append .signature, but someone might mail this. exit Larry Wall lwall@jpl-devvax.jpl.nasa.gov