#!/usr/bin/perl use strict; use warnings; use IMDB::Film; use LWP::Simple 'get'; my $imdb = new IMDB::Film(crit => '0442933'); die "Something went wrong: " . $imdb->error . "\n" if ! $imdb->status; for my $info (qw/title year plot rating/) { print ucfirst($info), ": ", scalar $imdb->$info, "\n"; } print "Recommendations:\n"; my $recs = fetch_recommendations($imdb); while (my ($id, $title) = each %$recs) { print "$id: $title\n"; } sub fetch_recommendations { my ($imdb) = @_; my $url = 'http://www.imdb.com/title/tt' . $imdb->id . '/recommendations'; my $content = get($url) || ''; my ($extract) = $content =~ /by the database(.*?)if you want to see if a movie /s; $extract = '' if ! defined $extract; my %rec; while ($extract =~ m|href="/title/tt(\d+)/">([^<]+)|g) { my ($id, $title) = ($1, $2); $rec{$id} = $title; } return \%rec; }