#!/usr/bin/perl $datafile = "/home/sites/www.yourname.com/users/web/mysites.txt"; ############ THE ACTUAL PROGRAM ############ &parse; &incomplete unless $FORM{'name'}; $name = "$FORM{'name'}"; &findurl; &doit; ############ SUBROUTINES ############ sub doit { print ("Location: $url\n"); print ("Content-type: text/html\n\n"); } ############ FIND URL ############ sub findurl { open (INFO, "$datafile"); @information = ; foreach $information (@information) { ($title, $location) = split(/\|/ , $information); { if ($title eq $name) { $url = $location; } } } close (INFO); } ############ PARSE ############ sub parse { read(STDIN, $input, $ENV{'CONTENT_LENGTH'}); $input = $ENV{'QUERY_STRING'} if $ENV{'QUERY_STRING'}; @pairs = split(/&/, $input); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } } sub incomplete { print "Content-type: text/html\n\n "; print <<"HTML"; Incomplete

Form not complete


Sorry, you forgot to enter something. You should go back and try again. HTML exit; }