+ my $rec = MARC::Record->new;
+ $rec->encoding( 'UTF-8' );
+ foreach my $field ( sort keys %{ $data->{$id} } ) {
+ foreach my $arr ( @{ $data->{$id}->{$field} } ) {
+ if ( ! $arr ) {
+ print STDERR "SKIPPED $id $field ",dump( $data->{$id} );
+ next;
+ }
+ $rec->add_fields( $field, @$arr );
+ }
+ }
+
+ #print $rec->as_formatted;
+ #print "# $id ",dump($data->{$id});
+
+ print $marc_fh $rec->as_usmarc;
+ $number++;
+ print "$number " if $number % 1000 == 0;