Originally published on: Sun, 07 Jun 2009 22:13:34 +0000
About a month ago, I wrote a short article called PHP, Transparent GIF's, and Web Tracking that turned out to be one of the more popular entries on this blog. If you haven't already, you might wish to read that posting first as it goes into more detail on the fundamentals of site tracking using transparent GIF images.
It's not the first time I'd written up a web application that delivers a tracking GIF to the client. The earliest implementation I can remember writing was written in Perl.
In the mid-90's, I used to write a lot of custom CGI ( Common Gateway Interface ) scripts in Perl. I opted to use PHP for the earlier article because it seems to now be more ubiquitous. Back in "the day", however, Perl was everywhere. Unfortunately, it wasn't always the same version of Perl on each site, nor was Apache always configured to recognize the same file extensions as CGI's the same way, nor was the Perl interpreter always found in the same spot.
Perl was always my trusted ally, however. Once the site's configuration was understood, I found Perl to be very easy to use.
I have noted that a number of hosting sites that offer PHP also offer some flavor of Perl. So, I thought I'd provide a short sample Perl CGI script that will deliver the same single-pixel GIF as the one used in the PHP article.
tracker.pl
I again left the actual logging as a fill-in for the reader. The code presented just writes a few CGI headers to a flat file.
I also did not implement any mechanism to convey a page identifier via a parameter as I did in the PHP article as I suspect a number of you use different approaches/libraries for parsing parameters. I used to use cgi-lib.pl because it was lightweight. I was aware that others were using different libraries and such, so I haven't placed any code to parse parameters from the querystring.
Unless otherwise noted, all code and text entries are Copyright ©2009 by James K. Lawless
Views expressed in this blog are those of the author and do not necessary reflect those of the author's employer. Views expressed in the comments are those of the responding individual.

Save to StumbleUpon
Digg it
Save to Reddit
Share on Facebook
Share on Twitter
More bookmarks
Click **here**
A JavaScript REPL for Android Devices
A Review of Kevin Mitnick's Book Ghost in the Wires
Play MP3 Files with Python on Windows
Invoking the Default Windows Screen-Saver
Extracting URL Addresses from Text in C
Getting the Windows Console Text Color
Thwarting HTTP Referer Trackbacks
Scott Ballantyne: Blazin' Into Forth
Choose your own Adventure with Sinatra
Screen Captures with Java and Clojure
Why Some Web Sites will go Dark on Jan 18th
Book Review : Paull Allen - Idea Man
A 90's Experiment in Online Systems - The U.S. West CommunityLink Service