Unspecified error (was Re: Z3950 returning two records?)

[email protected] (Sharif Islam)
Newsgroups perl.perl4lib
Message-ID <[email protected]>
I am using the same script to go though a text file that contains issn. 
After returning the subject for 20 entires (out of 500), the script
stop with the error mesage:
"Unspecified error at test.pl line 29"
line 29 is : my $rec = $rs->record(1)
The original code was:
for (my $i = 1; $i <= $n; $i++) {
 my $rec = $rs->record($i)
       or die $rs->errmsg();
my $m = MARC::Record->new_from_usmarc($rec->rawdata());
print $m->subfield('650',"a"), "\n";

To get only one entry I got rid of the for loop:
 
      my $rec = $rs->record(1)
         or die $rs->errmsg();
    my $m = MARC::Record->new_from_usmarc($rec->rawdata());
    print "$issn\t";
    print $m->subfield('650',"a"), "\n";

Any idea? Thanks.

--sharif


Sharif Islam wrote:

> I have this simple scripts that looks up ISSN and returns the subject. 
> Why it is returning two records for the same ISSN?
> use strict;  use Net::Z3950;
> use MARC::Record;
> use MARC::File::USMARC;
> use MARC::Field;
>
>
> my $conn = new Net::Z3950::Connection('z3950.loc.gov', 
> 7090,databaseName => 'Voyager');
> my $issn="0896-9205";
> my $query = '@attr 1=8 ' . $issn;
> $conn->option(preferredRecordSyntax => "USMARC", elementSetName => 'b');
> my $rs = $conn->search($query)
>        or die $conn->errmsg();
> my $n = $rs->size();
> print "found $n records\n";
> for (my $i = 1; $i <= $n; $i++) {
>  my $rec = $rs->record($i)
>        or die $rs->errmsg();
> my $m = MARC::Record->new_from_usmarc($rec->rawdata());
> print $m->subfield('650',"a"), "\n";
> #print $rec->render();
> }
>
> # perl test.pl
> found 2 records
> Sociology
> Sociology
>


-- 
Sharif Islam                 Research Programmer
Library Systems Office       University of Illinois Urbana-Champaign
http://www.library.uiuc.edu  phone:  (217) 244-4688
smime.p7s (application/x-pkcs7-signature, 3.2 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.