#!/usr/local/bin/perl

##############################################################################
# keyword.pl - Josiah Hamilton's keyword seeker special message script       #
# Use or modify freely, wisely, and at your own risk.                        #
#                                                                            #
# jqh1 at cornell.edu  http://beastie.law.cornell.edu/~hamilton              #
#                                                                            #
# This script is useful if certain users come to your page after searching   #
# for something in particular.  Using the script, you can send those users a #
# special message (such as the location of what they seek). The script works #
# by sensing the URL of the page that referred the user to your page, then   #
# determining whether that URL contains a key word that you specify. If it   #
# does, then the script ouputs your special message.  Note: this will only   #
# work with search engines (such as Infoseek) that include keywords in the   #
# URL of the results list (that is, they use GET method forms).              #
#                                                                            #
# To use the script, change the $keyword variable below to the key word you  #
# wish to sense, then change the $message variable to your intended message  #
# (if you use quotes in your message, be sure to precede them with a         #
# backslash (e.g., \").  Then execute the script on your page in the position#
# where you want the message to appear like so:                              #
# <--!#exec cgi="/cgi-bin/keyword.pl" -->                                    #
# Then delete these comments -- they're too darn long.                       #
##############################################################################

 $keyword = "mykeyword";
 $message = "<center>Oh seeker of $keyword, this is your lucky day.</center>";

# Hopefully, no editing will be necessary beyond this point.

 print "Content-type: text/html\n\n";
 if ($ENV{'HTTP_REFERER'} =~ /$keyword/){
    print "$message";
 }

exit;
