If only it were that simple. I actually posted an incorrect version of this script, my appologies. The script that I should have posted follows: (I had placed a number of print statements through the previous post which I had used to try and find the problem)
#!/usr/bin/perl -wT
use strict;
use IO::Socket;
use HTML::Entities;
require './libraryCommon.pl';
unless (@ARGV) { die "Exiting without parameter. (HINT: You need to p
+ass the ISBN)\n"; }
unless (testISBN($ARGV[0])) {
my $host="xml.amazon.com";
my $port=80;
my $buff="";
my $line;
my $title="";
my $date="";
my $manufacturer="";
my $author="";
my @author;
my $count=0;
my $isbn=$ARGV[0];
my $getBook="GET http://$host/onca/xml2?t=webservices-20&dev-t=D3N
+1ICFCFE4DHV&AsinSearch=$isbn&type=lite&f=xml HTTP/1.0\
\n\n";
my $sock=new IO::Socket::INET(PeerAddr => $host, PeerPort => $port
+, Proto => 'tcp') or die "Couldn't connect to $host";
$sock->autoflush(1);
print $sock $getBook;
$count=0;
while (<$sock>) {
decode_entities($_);
if (m%<ProductName>(.*?)</ProductName>%) { $title = $1 }
elsif (m%<Author>(.*?)</Author>%) {
$author[$count]=$1;
$count++;
}
elsif (m%<ReleaseDate>.*, (\d\d\d\d)</ReleaseDate>%) { $date=$
+1; }
elsif (m%<Manufacturer>(.*?)<\/Manufacturer>%) { $manufacturer
+=$1; }
}
close($sock);
print $title, "\n";
foreach $author (@author) { print $author, "\n" };
print $date, "\n";
print $manufacturer, "\n";
}
else { die "Exiting due to the fact that you have supplied an invalid
+ISBN."; }
|