#!/usr/bin/perl use CGI; use strict; use imdb; my $movie = CGI::param('movie'); my $imdb = IMDB->new(); my %res = IMDB->query('title' => $movie); if ($res{best_title_1}) { select_movie(); } elsif ($res{imdb_title}) { valid_asis(); } else { fail(); } sub fail() { print "Content-type: text/html\n\n"; print "Your submission: $movie didn't match anything. Try again"; } sub valid_asis() { print "Location: record.cgi?movie=$res{imdb_title}\n\n"; } sub select_movie() { my ($key, $value); print "Content-type: text/html\n\n"; print "

Multiple Results


Please select from the following:
"; print "
\n"; while (($key,$value) = each %res) { if (index($key, "best_title_") != -1) { print "$value
\n"; } } print "

If you selection is not present, please try being more specific. Try again."; }