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
Save to del.icio.us
Save to StumbleUpon
Digg it
Save to Reddit
Share on Facebook
Share on Twitter
More bookmarks
Subscribe!
Auto Save Clipboard Images Redux
Extending SpiderMonkey JavaScript on Windows
Rhino JavaScript to EXE with launch4j
Compiling Rhino JavaScript to Java
Directory Traversal in Rhino JavaScript
A Command-Line MP3 Player for Windows
Auto Save Images from the Clipboard
Java in a Windows EXE with launch4j
An Interview with Tom Zimmer: Forth System Developer
Setting Windows Console Text Colors in C
Windows Text to Speech in WSH JavaScript
BSave and BLoad for the Commodore 64
A Simple Parser for a Small Command Line Interface
Screen Capture from Multiple Monitors in Java
Java in a Windows EXE with launch4j
MicroISV on a Shoestring
DadHacker
The Bottom Feeder
Writin' That Code!
The Recursive ISV
The Thomsen Blog
Prototypically Speaking
The Reinvigorated Programmer