1#!/usr/bin/perl
2###########################################
3use warnings;
4use strict;
5
6use Net::Amazon;
7#use Log::Log4perl qw(:easy);
8#Log::Log4perl->easy_init($DEBUG);
9
10my $ua = Net::Amazon->new(
11    associate_tag => $ENV{AMAZON_ASSOCIATE_TAG},
12    token         => $ENV{AMAZON_TOKEN},
13    secret_key    => $ENV{AMAZON_SECRET_KEY},
14);
15
16die "usage: $0 upc [mode]\n(use " .
17    "'093624843627 music' as an example)\n"
18    unless defined $ARGV[0];
19
20
21my %options;
22$options{upc}  = $ARGV[0];
23$options{mode} = $ARGV[1] if defined $ARGV[1];
24
25my $resp = $ua->search(%options);
26
27if($resp->is_success()) {
28    print $resp->as_string(), "\n";
29} else {
30    print "Error: ",
31          $resp->message(), "\n";
32}
33