#!/usr/bin/perl
######################################################
# Power Search
# Martin Streicher <martin.streicher@apress.com>, 2003
# Mike Schilli <na@perlmeister.com>, 2003
######################################################
use warnings;
use strict;

use Net::Amazon;

#use Log::Log4perl qw(:easy);
#Log::Log4perl->easy_init($DEBUG);

die "usage: $0 phrase mode\n".
    "(use 'subject: perl and author: schwartz' books as an example)\n"
    unless defined $ARGV[1];

my $ua = Net::Amazon->new(
    token       => 'MY_AMAZON_TOKEN',
    max_pages   => 5,
);

my $req = Net::Amazon::Request::Power->new(
    power     => $ARGV[0],
    mode      => $ARGV[1],
);

 # Response: Net::Amazon::Keyword::Response
my $resp = $ua->request($req);

die "Error" unless $resp->is_success();

for ($resp->properties) {
   print $_->Asin(), " ",
         $_->title(), " ",
         $_->OurPrice(), "\n";
}
