--- trunk/lib/WebPAC/Normalize.pm 2006/09/08 17:47:58 661 +++ trunk/lib/WebPAC/Normalize.pm 2006/09/11 12:56:05 667 @@ -36,11 +36,11 @@ =head1 VERSION -Version 0.18 +Version 0.19 =cut -our $VERSION = '0.18'; +our $VERSION = '0.19'; =head1 SYNOPSIS @@ -732,7 +732,6 @@ my ($h,$include_subfields) = @_; - if ( defined($h->{subfields}) ) { my $sfs = delete $h->{subfields} || die "no subfields?"; my @out; @@ -742,16 +741,34 @@ my $o = shift @$sfs; if ($o == 0 && ref( $h->{$sf} ) ne 'ARRAY' ) { # single element subfields are not arrays +warn "====> $sf $o / $#$sfs ", dump( $sfs, $h->{$sf} ), "\n"; + push @out, $h->{$sf}; } else { -#warn "====> $f $sf $o $#$sfs ", dump( $sfs ), "\n"; +warn "====> $sf $o / $#$sfs ", dump( $sfs, $h->{$sf} ), "\n"; push @out, $h->{$sf}->[$o]; } } - return @out; + if ($include_subfields) { + return join('', @out); + } else { + return @out; + } } else { - # FIXME this should probably be in alphabetical order instead of hash order - values %{$h}; + if ($include_subfields) { + my $out = ''; + foreach my $sf (keys %$h) { + if (ref($h->{$sf}) eq 'ARRAY') { + $out .= '^' . $sf . join('^' . $sf, @{ $h->{$sf} }); + } else { + $out .= '^' . $sf . $h->{$sf}; + } + } + return $out; + } else { + # FIXME this should probably be in alphabetical order instead of hash order + values %{$h}; + } } }