dlind has asked for the wisdom of the Perl Monks concerning the following question:

Hello! I am a fairly new wielder of the perl and have got a question regarding the module IMDB::Film. Here's my code:
1 #!/usr/bin/perl 2 3 use strict; 4 use IMDB::Film; 5 6 my $film = <>; 7 my $imdbobject = new IMDB::Film(crit => $film); 8 9 if($imdbobject ->status) { 10 print "Title: ".$imdbobject->title(). "\n"; 11 print "Year: ".$imdbobject->year(). "\n"; 12 print "Plot: ".$imdbobject->year(). "\n"; 13 } else { 14 print "Something went wrong"; 15 }
And the output from when I try running the program as such: perl imdb.pl moviename ..
Can't open troy: No such file or directory at imdb.pl line 6. Film IMDB ID or Title should be defined! at imdb.pl line 7
Any ideas? /David

Replies are listed 'Best First'.
Re: IMDB::Film question
by toolic (Bishop) on Aug 02, 2010 at 19:52 UTC
      That did the trick. Care to explain? :) /David
        shift, with no arguments, and when not in a subroutine, shifts elements off of the @ARGV array (the command line args, see perlvar). The <> operator is a shortcut to readline (sort of, see perlop, and with no arguments, will open files named in @ARGV and read lines from the file.
Re: IMDB::Film question
by apl (Monsignor) on Aug 03, 2010 at 11:10 UTC
    As a follow-up to the answer toolic gave you, you might replace
        print "Something went wrong";
    with
        print "Something went wrong loading '$film'";

    That way, you'll be able to see typos, wrong path names, the fact that the path was null, etc.