$ISSN = $ISSN->{content};
}
my $url = qq(http://www.ncbi.nlm.nih.gov/nlmcatalog/?term=${ISSN}[ISSN]&format=text&report=xml);
- print STDERR "url: $url" if $DEBUG;
+ print STDERR "url: $url\n" if $DEBUG;
my $request = HTTP::Request->new('GET', $url);
my $response = $ua->request($request);
$response = $response->content;
$response =~ s/\</</gso;
$response =~ s/^<\/?pre>//;
- print STDERR "response: $response" if $DEBUG;
+ print STDERR "response: $response\n" if $DEBUG;
my $xa = new XML::Simple;
my $ref_struct = $xa->XMLin($response,ForceArray=>['NCBICatalogRecord'],KeyAttr=>[]);
- my $ref = $ref_struct->{NCBICatalogRecord}[0];
+ my $ref;
+ for (0..@{$ref_struct->{NCBICatalogRecord}}) {
+ if (exists $ref_struct->{NCBICatalogRecord}[$_]{JrXml}) {
+ $ref = $ref_struct->{NCBICatalogRecord}[$_];
+ last;
+ }
+ }
+ $ref = $ref_struct->{NCBICatalogRecord}[0] if not defined $ref;
print STDERR Dumper($ref) if $DEBUG;
my %journal;
$journal{lc($2)} = $3;
}
}
+ print STDERR Dumper($ref) if $DEBUG;
if (ref $ref->{JrXml}{Serial}{ISSN} ne 'ARRAY') {
$ref->{JrXml}{Serial}{ISSN} = [$ref->{JrXml}{Serial}{ISSN}];
}
+ print STDERR Dumper($ref->{JrXml}) if $DEBUG;
my $print_issn = $ref->{JrXml}{Serial}{ISSN}[0]{IssnType} eq 'Print' ? 0 : 1;
my @journal_entry =
(title => $ref->{JrXml}{Serial}{Title},