in reply to Understanding how to *use* a CPAN module

If you get lost in that maze of OOO, (I did:), you might like to try something like:

#! perl -slw use strict; use LWP::Simple; use XML::Simple; use Data::Dump qw[ pp ]; use constant ACCESS_ID => 'XXXXXXXX'; ## Your access key here. my $isbn = $ARGV[ 0 ] or die 'Need an ISBN number'; die "'$isbn' doesn't look like a valid ISBN" unless $isbn =~ m[^\d{10}$]; my $uri = sprintf "http://isbndb.com/api/books.xml?access_key=%s&index1=isbn&value1= +%s", ACCESS_ID, $isbn; my $xml = get $uri or die "Request failed"; my $info = XMLin $xml; pp $info;

A sample usage:

C:\test>isbndb 0131101633 { BookList => { BookData => { AuthorsText => "Brian W. Kernighan, Dennis M. Ritchie", PublisherText => { content => "Englewood Cliffs, N.J. : Prentice-Hall, c1978.", publisher_id => "prentice_hall_a01", }, Title => "The C programming language", TitleLong => {}, book_id => "the_c_programming_language", isbn => "0131101633", }, page_number => 1, page_size => 10, shown_results => 1, total_results => 1, }, server_time => "2008-04-22T03:13:35Z", }

Wrapping that into a module with an api like:

use ISBNDB::Simple ACCESSID => 'XXXXXXXX'; my $isbn = ...; my $href = Book( $isbn );

Is left as an exercise :)


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^2: Understanding how to *use* a CPAN module
by bradcathey (Prior) on Apr 22, 2008 at 13:00 UTC

    BrowserUk,

    Thanks for the "hand-rolled" version. I will be back if I can't get the aforementioned module working.

    —Brad
    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot

        Ha! No clue. I actually did ask myself that, but obviously I'm no expert on this module :-)

        —Brad
        "The important work of moving the world forward does not wait to be done by perfect men." George Eliot