koacamper has asked for the wisdom of the Perl Monks concerning the following question:
$name\|$url
Any help would be greatly appreciated#!/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 = <INFO>; 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"; <HTML><HEAD><TITLE>Incomplete</TITLE></HEAD> <BODY bgcolor=white> <H1>Form not complete</H1> <p> <hr noshade size=1> <p> Sorry, you forgot to enter something. <a href=\"$ENV{'HTTP_REFERER'}\">You should go back and try again</a>. </BODY> </HTML> HTML exit; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Error 404 fix
by chromatic (Archbishop) on Sep 30, 2000 at 20:28 UTC | |
by koacamper (Acolyte) on Sep 30, 2000 at 22:35 UTC | |
|
(Ovid) Re: Error 404 fix
by Ovid (Cardinal) on Sep 30, 2000 at 21:01 UTC | |
|
Re: Error 404 fix
by clemburg (Curate) on Sep 30, 2000 at 20:51 UTC |