#!/usr/bin/perl

    # First open my database.  Complain if unable.

open(STUFF, "stuff") || die "Can't open stuff: $!\n";

    # Open the clay tablet printer.

open(CTP, ">/dev/ctp") || die "Can't open /dev/ctp: $!\n";

    # Now load stuff into associative array.

while (<STUFF>) {
    ($beastie,$remainder) = split(/:/, $_, 2);
    $beastie =~ tr/A-Z/a-z/;
    $stuff{$beastie} = $remainder;
}

close STUFF;

   # Now loop forever, printing out letters on demand.

while (1) {

    # Find out what to do next.

    print "Letter for which beastie: ";
    chop($beastie = <STDIN>);
    last unless $beastie;

    # Get the information handy for selected beastie.

    ($noses, $hazard, $premium) = split(/:/, $stuff{$beastie});
    $payment = $premium * $noses;

    # Now print out the letter.

    print CTP <<"EndOfLetter";
Dear Shekelgrubbers:

    Please find enclosed $payment shekels in payment of the
annual premium for insuring $noses of my $beastie against
$hazard.

				Sincerely,
				   Job

Quote of the day:
    "You can lead a camel to water, but you can't make
     it stink (any worse than it already does)."
EndOfLetter

    print CTP "\f";            # Eject the clay tablet.
}
