The following code iterates unexpectedly. I want to loop thru the file 'file.dat' and pull out every field that begins with 650. The code then pulls the 650 field and builds an array from the sub-fields. The code works but I'm stuck on the first record. In other words if the file I'm reading has 2000 records I get the first 650 record 2000X
use MARC::Batch;
my $batch =MARC::Batch->new('USMARC','file.dat');
my $record = $batch->next();
## get all the 852 fields (list context).
my @fields = $record->field('852');
## examine each 852 field and print it out.
while (my $record = $batch->next())
{
foreach my $field (@fields) {
print $field->as_string(),"\n";
}
}
I don't know anything about the MARC::Batch module, but I notice that the foreach loop is running independently from variables set in the
while() loop. Consequently, it does not surprise me when you say that
you are "stuck".
Btw, why don't you enable strictures and warnings?
-- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
