#!/usr/local/bin/perl #------------------------------------------------------------------------------ # Webmonkey Movie Database v1.0 # Written by Colin Ferm # ferm@wired.com # # Feel free to use this for your own purposes, changing it as you wish. Please # leave this header in all modifications, noting the changes made, and adding # your name to the author field. That's all we ask, and that you send on a URL # to wherever it's used, just so I can see all the neat things people might # do with it. # # 1.0 - First written for a Webmonkey article by Colin Ferm 11/24/98 #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ # Below is the standard input-getter thingy, which will grab the input regardless # of whether it's "get" or "post," and will save it to $in. #------------------------------------------------------------------------------ my $in; if ($ENV{'REQUEST_METHOD'} eq "GET") { $in = $ENV{'QUERY_STRING'}; } else { $in = ; } #------------------------------------------------------------------------------ # The first line pulls out the "+"s that should be spaces, and the second # line converts URI characters back to nonalphanumeric characters. # The line after that splits the input into %movie. #------------------------------------------------------------------------------ $in =~ s/\+/ /g; $in =~ s/%(..)/pack("c",hex($1))/ge; my %movie = split (/=/, $in); #------------------------------------------------------------------------------ # These lines read the database in to the variable @data and close the file. #------------------------------------------------------------------------------ open (DATA, "/usr/people/ferm/movies.dat"); my @data = ; close (DATA); #------------------------------------------------------------------------------ # This first print prints out the top of the document with the
Make your own free website on Tripod.com
tags # and just generally sets the flavor of the look of the page. #------------------------------------------------------------------------------ print <

Results


END #------------------------------------------------------------------------------ # This for loop is the real meat of the script. It runs through the array # looking for the title, then prints the relevant info out (depending on if # it's there or not). #------------------------------------------------------------------------------ for ($i = 0; $i <= $#data; $i++) { if ($data[$i] =~ /-- $movie{'title'} --/i) { print <$data[$i + 1]
$data[$i + 2]
END last; } elsif ($i == $#data) { print "Sorry! I haven't reviewed that one yet!"; } } #------------------------------------------------------------------------------ # This prints out the footer of the document. #------------------------------------------------------------------------------ print <
END