- type => $config->{$use_indexer}->{type},
- ) if ($indexer && $ds);
-
- if ($marc_fh) {
- my $marc = new MARC::Record;
- $marc->encoding( 'utf-8' );
- my @marc_fields = WebPAC::Normalize::_get_marc_fields();
- if (! @marc_fields) {
- $log->warn("MARC record $mfn is empty, skipping");
- } else {
- $marc->add_fields( @marc_fields );
-
- # tweak leader
- if (my $new_l = WebPAC::Normalize::marc_leader()) {
-
- my $leader = $marc->leader;
-
- foreach my $o ( keys %$new_l ) {
- my $insert = $new_l->{$o};
- $leader = substr($leader, 0, $o) .
- $insert . substr($leader, $o+length($insert));
- }
- $marc->leader( $leader );
- }
-
- if ($marc_lint) {
- $lint->check_record( $marc );
- my $err = join( "\n", $lint->warnings );
- $log->error("MARC lint detected warning on MFN $mfn\tleader:", $marc->leader(), "\n",
- ">>>>> Original imput row:\n",dump($row), "\n",
- ">>>>> Normalized MARC row:\n",dump(@marc_fields), "\n",
- ">>>>> MARC lint warnings:\n",$err,"\n"
- ) if ($err);
- }
-
- if ($marc_dump) {
- $log->info("MARC record on MFN $mfn\tleader:", $marc->leader(), "\n",
- ">>>>> Original imput row:\n",dump($row), "\n",
- ">>>>> Normalized MARC row:\n",dump(@marc_fields), "\n",
- );
- }
-
- print $marc_fh $marc->as_usmarc;
- }
+ type => $config->get($indexer_config)->{type},
+ ) if $indexer;
+
+ foreach my $out ( @output_modules ) {
+ $out->add( $mfn, $ds ) if $out->can('add');
+ }
+
+ } else {
+ $log->warn("record $pos didn't produce any output after normalization rules!") unless $marc;
+ }
+ if ($marc) {
+ my $i = 0;
+
+ while (my $fields = WebPAC::Normalize::MARC::_get_marc_fields( fetch_next => 1 ) ) {
+ $marc->add(
+ id => $mfn . ( $i ? "/$i" : '' ),
+ fields => $fields,
+ leader => WebPAC::Normalize::MARC::_get_marc_leader(),
+ row => $row,
+ );
+ $i++;