--- trunk/lib/WebPAC/Normalize.pm 2006/07/03 21:08:07 574 +++ trunk/lib/WebPAC/Normalize.pm 2006/07/05 00:12:08 583 @@ -35,11 +35,11 @@ =head1 VERSION -Version 0.10 +Version 0.11 =cut -our $VERSION = '0.10'; +our $VERSION = '0.11'; =head1 SYNOPSIS @@ -326,7 +326,7 @@ warn "## saved/3 ", dump( $field ),$/ if ($debug); } - return @m; + return \@m; } =head2 _debug @@ -504,6 +504,8 @@ my ($i1,$i2) = defined($marc_indicators->{$f}) ? @{ $marc_indicators->{$f} } : (' ',' '); my $m = [ $f, $i1, $i2 ]; + warn "### marc_compose input subfields = ", dump(@_),$/ if ($debug > 2); + while (@_) { my $sf = shift or die "marc_compose $f needs subfield"; my $v = shift; @@ -565,7 +567,8 @@ warn "### marc_remove before = ", dump( $marc ), $/ if ($debug > 2); - foreach my $i ( 0 .. $#{ $marc } ) { + my $i = 0; + foreach ( 0 .. $#{ $marc } ) { last unless (defined $marc->[$i]); warn "#### working on ",dump( @{ $marc->[$i] }), $/ if ($debug > 3); if ($marc->[$i]->[0] eq $f) { @@ -591,6 +594,7 @@ } } } + $i++; } warn "### marc_remove($f", $sf ? ",$sf" : "", ") after = ", dump( $marc ), $/ if ($debug > 2); @@ -658,10 +662,16 @@ =cut sub rec { + my @out; if ($#_ == 0) { - return rec1(@_); + @out = rec1(@_); } elsif ($#_ == 1) { - return rec2(@_); + @out = rec2(@_); + } + if (@out) { + return @out; + } else { + return ''; } } @@ -767,7 +777,9 @@ sub join_with { my $d = shift; - return join($d, grep { defined($_) && $_ ne '' } @_); + my $v = join($d, grep { defined($_) && $_ ne '' } @_); + return '' unless defined($v); + return $v; } =head2 split_rec_on