#!/usr/bin/perl
use IMDB::Film;
use Data::Dumper;
use strict;

my $imdbObj = new IMDB::Film(crit => join(" ",@ARGV));
if($imdbObj->status) {
    print "Title: ".$imdbObj->title()."\n";
    print "Year: ".$imdbObj->year()."\n";
    my $genre = join(", ", @{$imdbObj->genres()}[0..2]);
    $genre =~ s/\W*\z//g;
    print "Genre: $genre\n";
    my @cast;
    foreach my $hash ( @{$imdbObj->cast()} ) {
	push(@cast, $hash->{name});
    }
    my $actors = join(", ", @cast[0..2]);
    $actors =~ s/\W*\z//g;
    print "Cast: $actors\n";
    my $plot = $imdbObj->plot();
    $plot =~ s/full summary.*//g;
    $plot =~ s/\. .*\|.*/./g;
    print "Plot Summary: $plot\n";
    my($rating, $vnum) = $imdbObj->rating();
    print "Rating: $rating ($vnum)\n";
    my $coverurl = $imdbObj->cover();
    print "Duration: " . $imdbObj->duration()."\n";
    print "\n"
} else { 
    print "Something wrong: ".$imdbObj->error; 
}
