> -----Original Message----- > From: Aaron Huber [mailto:[EMAIL PROTECTED] > Sent: Monday, November 21, 2005 10:33 PM > To: perl4lib@perl.org > Subject: MARC.pm unblessed reference > > > Hi All, > > I am a complete newbie to this and have been testing out MARC.pm. > I'm trying to return just the ISBN values from a group of MARC > records. It works fine when I specify the record number, but when I > put it through the loop it returns the above error.
My recommendation would be that you try to switch from MARC.pm to the MARC::Record distribution (see a previous posting to this list <http://www.nntp.perl.org/group/perl.perl4lib/2166>). Then the code below should accomplish what you want (though I have not tested it as it appears in this message--see <http://home.inwave.com/eija/fullrecscripts/Extraction/extractisbn.txt> for the original version, for which you would need to also install my MARC::BBMARC (from my website or MARC::Errorchecks from CPAN, which includes that module)). In my modified version below, I extract only subfield 'a' of the 020, and I clean the field to (hopefully) leave only the ISBN portion of the field--removing any qualifiers. It should be easy enough to modify the code to extract the entire 020 field as_string() and report it. I hope this helps, Bryan Baldus [EMAIL PROTECTED] [EMAIL PROTECTED] http://home.inwave.com/eija ############################ #!perl =head2 Extracts ISBN from file of MARC records. =cut ########################### ### Initialize includes ### ### and basic needs ### ########################### use strict; #MARC::Batch is installed as part of MARC::Record use MARC::Batch; ######################### ### Start main program ## ######################### my $inputfile= 'marc.dat'; #my $exportfile = 'out.dat'; #open(OUT, ">$exportfile") or die "Problem opening $exportfile, $!"; #initialize $batch as new MARC::Batch object my $batch = MARC::Batch->new('USMARC', "$inputfile"); ########## Start extraction ######### my $runningrecordcount=0; #### Start while loop through records in file ##### while ( my $record = $batch->next() ) { $runningrecordcount++; #get control number for reporting #my $controlno = $record->field('001')->as_string() if ($record->field('001')); ### loop through each 020 field ### for my $field020 ( $record->field("020") ) { my $isbn = $field020->subfield('a') if ($field020->subfield('a')); if (defined ($isbn)) { #remove any hyphens $isbn =~ s/\-//g; #remove nondigits $isbn =~ s/^\D*(\d{9,12}[X\d])\b.*$/$1/; # Now report it print $runningrecordcount, ": ", $isbn, "\n"; } # if isbn defined } # for } # while ########################## ### Main program done. ## ########################## ##################### ### END OF PROGRAM ## #####################