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 :)
|
|---|
| 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 | |
by BrowserUk (Patriarch) on Apr 22, 2008 at 14:39 UTC | |
by bradcathey (Prior) on Apr 22, 2008 at 16:50 UTC | |
by BrowserUk (Patriarch) on Apr 22, 2008 at 18:00 UTC |