Slide 67
Slide 67 text
Item => $item_id,
Loc => '',
Prof => 'XHTML',
});
my $res = $ua->get($uri);
return unless $res->is_success;
my $xml = XML::Simple::XMLin(
$res->content,
SuppressEmpty => 1, # returns empty element.
);
if ($type eq 'e2j') {
my $caption = $xml->{Head}->{div}{span}{content};
if ($caption =~ s/\.$//) {
my @results = split /\s+/, $xml->{Body}->{div}{div};
sprintf '%d results: %s', scalar @results, join ', ',
@results;
} else {
sprintf '[%s] %s', $caption, join "\n", split /\s+/,
$xml->{Body}->{div}{div};
}
} else {
(my $caption = $xml->{Head}->{div}{span}{content}) =~ s/\n*
\s+.*$//ms;
my $stuff = $xml->{Body}->{div}{div}{div};
if (ref $stuff eq 'ARRAY') {
sprintf '[%s] %s', $caption, join ', ', @{$xml->{Body}-
>{div}{div}{div}};
} else {
sprintf '[%s] %s', $caption, $stuff;
}
}
}