Stillwater Sign by Slim


[an error occurred while processing this directive]

The above Zippyism should change every time you refresh this page.

 I created this page as an exercise in perl cgi programming, and how to embed it in web pages.   Apologies to Zippy creator Bill Griffith.  Anyone that has used the EMACS editor should know about the old META X insert-zippyism, apropos-zippy, etc.  These (like all) Emacs extensions are written in Lisp, and I never did get a handle on the intricacies of Lisp programming.  Perl, however, is very C-ish, and a no brainer for me.  The main hurdle was to understand the way perl handles text files.  The zippy quotes for Emacs are stored in <emacs_install_path>/etc/yow.lines.  It is actually a collection of about 750 NULL terminated strings.  In C, parsing this would not be a problem, and as it turns out, it's even easier in Perl.  Because most text handling routines in perl are line oriented, the record separator is by default NL (new line).or CR (carriage return), NL  depending on whether you are on a Windows or UNIX system.   Because yow.lines has NL embedded in what is intended to be a single string, the default record separator does not work.  All that needs to be done is to change the record separator ($/) to "\0".  After reading the file into an array, it might be nice to restore the record separator to whatever it was previously.

Wups!  Just fired up the linux box and learned that I was leaving the NULL terminator in the string, so had to chomp it off.

$old_rs = $/; #record separator
$/ = "\000"; #new record separator (NULL Terminated)
$YOW_FILE = "pathtoyow/yow.lines";
open YOW_FILE;
@array = <YOW_FILE>;
# Print a header
print "Content-type: text/html\n\n";
## There are 13 lines of carriage return terminated text in yow.lines, but we're looking for NULL terminated
## So, no offset required
$count = @array;
$index = rand($count - 1);
print "<br>";
$mystring = $array[$index];
print $mystring;
$/ = $old_rs;

Document made with KompoZer