/misc/p6.cgi

#!/bin/bash

echo Content-Type: text/html; encoding=utf-8
echo 

SPEC=${PATH_INFO#/}
case $SPEC in
   S01) SPEC=S01-overview;; 
   S02) SPEC=S02-bits;;
   S03) SPEC=S03-operators;;
   S04) SPEC=S04-control;;
   S05) SPEC=S05-regex;;
   S06) SPEC=S06-routines;;
   S07) SPEC=S07-iterators;;
   S09) SPEC=S09-data;;
   S10) SPEC=S10-packages;;
   S11) SPEC=S11-modules;;
   S12) SPEC=S12-objects;;
   S13) SPEC=S13-overloading;;
   S14) SPEC=S14-roles-and-parametric-types;;
   S16) SPEC=S16-io;;
   S17) SPEC=S17-concurrency;;
   S19) SPEC=S19-commandline;;
   S21) SPEC=S21-calling-foreign-code;;
   S22) SPEC=S22-package-format;;
   S26) SPEC=S26-documentation;;
   S28) SPEC=S28-special-names;;
   S29) SPEC=S29-functions;;
   S31) SPEC=S31-pragmatic-modules;;
   *) echo error; exit 1;;
esac

echo '<!DOCTYPE html>'
echo "<title>$SPEC</title>"
echo '<pre>'
curl -s http://svn.pugscode.org/pugs/docs/Perl6/Spec/${SPEC}.pod | \
   (for ((i=1; i<100000000; i++))
    do read LINE || break
       echo "$i $LINE"
    done) | \
   sed 's%&%\&amp;%; s%<%\&lt;%; s%[0-9]*%<span id="&">%; s%$%</span>%'
echo '</pre>'