I don't quite know how the code looks, but if you eliminate this loop don't
you let the case where n = 0 slip thru, so you will try to access record 1 even when there
is none?
just my 2 cents,
Rick

Sharif Islam wrote:
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





--
******************************
Enrico Silterra
Meta Data Engineer
107-E Olin Library
Cornell University
Ithaca NY 14853

Voice: 607-255-6851
Fax:     607-255-6110
E-mail: [EMAIL PROTECTED]
http://www.library.cornell.edu/cts/
"We must walk consciously only part way toward our goal, and then leap in the dark 
to our success."  - - Thoreau
******************************

Reply via email to