mike re-v wrote:

Note: forwarded message attached.




__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail



------------------------------------------------------------------------

Subject:
loop nested foreach
From:
"re-v" <[EMAIL PROTECTED]>
Date:
Mon, 21 Jun 2004 16:03:02 -0400
To:
Gunnar Hjalmarsson <[EMAIL PROTECTED]>

To:
Gunnar Hjalmarsson <[EMAIL PROTECTED]>


the idea here is to step thru a file named file.dat
and extract part of each record {fields}. each record has sub components (tags) which are subdivided in a [EMAIL PROTECTED]).
what am I doing wrong?
tia
re-v


     ## Example R6
          use MARC::Batch;
    # use strict;
    #  use warnings;

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 $record= my $field (@fields) {

This is a syntax error. The correct syntax is:

                    foreach  my $field (@fields) {

      print $field->as_string(),"\n";

                   } # end foreach
       } # end while



$perl fieldsrepeat.pl
syntax error at fieldsrepeat.pl line 22, near "$record="
syntax error at fieldsrepeat.pl line 25, near "}"
Execution of fieldsrepeat.pl aborted due to compilation errors.









--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to