#!/cgi-bin/homestead/perl # 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, "movies.dat"); my @data = ; close (DATA); #----------------------------------------------------------------# This first print prints out the top of the document with the # 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