Puffin Handbook -- Perl Examples



These are some simple examples using Perl for CGI. Try testing them out in your own website, and adding features and enhancements.




Hello Puffin

Hello Puffin demonstrates the generation of on-the-fly HTML.

hellopuffin.pl

Hello Puffin source


Seconds Since

Seconds Since demonstrates using CGI to present dynamic information.

secondssince.pl

Seconds Since source


Jumpbox

This script is actually quite useful. It allows for a 'jumpbox' similar to the one you see at http://www.ptialaska.net.

jumpbox_demo.html

Jumpbox source


Gary's Access Logger

This access logger was built to Gary's spec, so I named it for him. This is pretty complex, so watch closely.

You need to have a 'splash' page, and it should be the default page in the directory. (index.htm). On that page, you either make a link, or have a javascript relocation, to the script, which then deposits the user on the real destination, without the user being aware they have been redirected. The reason for these shenanigans is that we need to pass the name of the web site that the user clicked from to the perl script, but if we just go to the perl script, the only referrer is our own page, so we need to pass the 'original' off-site referrer by means of javascript. Still with me?

Okay, here is how I implemented the javascript redirection.

<HTML>
<BODY ONLOAD="location.href='accesslog.pl?referrer='+ document.referrer">
</BODY>
</HTML>

You may want to do some chacking to see if the browser is up to spec.... or simply a link that goes to the proper page anyways. Pre-netscape 2.0, and pre IE 3 won't do javascript at all.

accesslog_demo.htmaccesslog source


©1998 PTI NET Alaska, All Rights Reserved
email The Puffin with comments, criticisms, and concerns.