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

Dear Monks, Could someone please comment on solutions to the following error. I am using the Library of Congress driver to look up book info based on ISBN numbers. I am not clear on how to combine the driver pm file with the script, etc.
use WWW::Scraper::ISBN::Driver; use WWW::Scraper::ISBN::LOC_Driver; $driver = WWW::Scraper::ISBN::LOC_Driver->new(); $driver->search("0764516965"); $driver->verbosity(1); my $book = $driver->book(); print $book('title'); print $driver->error;
and here is the result :
Can't use an undefined value as a symbol reference at isbn_lookup2.pl +line 9.
Many thanks!

Replies are listed 'Best First'.
Re: WWW::Scraper::ISBN::Driver
by traveler (Parson) on Jul 26, 2006 at 22:53 UTC
    There are two problems: first, your line
    print $book('title');
    should be
    print $book->{'title'};
    as $book is a hashref.

    More importantly, the module goes to the wrong site. It goes to lcweb.loc.gov which is now www.loc.gov. Editing the module fixes that. You should probably contact the author and let him know. His contact information is in the CPAN documentation.

    Here is my (working after changing LOC_Driver) code:

    use WWW::Scraper::ISBN::Driver; use WWW::Scraper::ISBN::LOC_Driver; $driver = WWW::Scraper::ISBN::LOC_Driver->new(); $LOC = "0764516965"; $driver->verbosity(1); $driver->search($LOC); die " $LOC Not Found" if ! $driver->found; print "Here is the info on $LOC\n"; print ref $book; my $book = $driver->book; print $book->{title};

    HTH, --traveler

      Thank you! Works perfectly now. Reported the URL problem to the module author also. Cheers!
Re: WWW::Scraper::ISBN::Driver
by ikegami (Patriarch) on Jul 26, 2006 at 22:45 UTC

    Replace
    print $book('title');
    with
    print $book->{'title'};

    I see it's in the module's synopsis, but $book('title') is definitely wrong. If you scroll down to book, you'll see $book->{'title'} used.