1#!/usr/bin/perl 2########################################### 3# maxauthors keyword 4# Search books by keyword and select those 5# with the highest number of authors. 6# Mike Schilli <mschilli1@aol.com>, 2003 7########################################### 8 9use strict; 10use warnings; 11 12use Net::Amazon; 13use Net::Amazon::Property; 14use Net::Amazon::Request::Keyword; 15 16die "usage: $0 keyword" unless 17 defined $ARGV[0]; 18 19my $ua = Net::Amazon->new( 20 associate_tag => $ENV{AMAZON_ASSOCIATE_TAG}, 21 token => $ENV{AMAZON_TOKEN}, 22 secret_key => $ENV{AMAZON_SECRET_KEY}, 23 max_pages => 10, 24); 25 26my $req = Net::Amazon::Request::Keyword->new( 27 keyword => $ARGV[0], 28 mode => "books" 29); 30 31 # Response: Net::Amazon::Keyword::Response 32my $resp = $ua->request($req); 33 34my $max_authors = 0; 35my @books = sort { 36 scalar $b->authors() <=> 37 scalar $a->authors() } 38 grep { $_->title() =~ /$ARGV[0]/i } 39 $resp->properties; 40 41for(0..4) { 42 print scalar $books[$_]->authors, 43 " ", $books[$_]->as_string, "\n\n"; 44} 45