--- trunk/lib/WebPAC/Normalize.pm 2006/08/25 12:31:06 619 +++ trunk/lib/WebPAC/Normalize.pm 2006/09/06 14:25:16 631 @@ -36,11 +36,11 @@ =head1 VERSION -Version 0.16 +Version 0.17 =cut -our $VERSION = '0.16'; +our $VERSION = '0.17'; =head1 SYNOPSIS @@ -740,7 +740,26 @@ if (ref($rec->{$f}) eq 'ARRAY') { return map { if (ref($_) eq 'HASH') { - values %{$_}; + my $h = $_; + if ( defined($h->{subfields}) ) { + my $sfs = delete $h->{subfields} || die "no subfields?"; + my @out; + while (@$sfs) { + my $sf = shift @$sfs; + my $o = shift @$sfs; + if ($o == 0 && ref( $h->{$sf} ) ne 'ARRAY' ) { + # single element subfields are not arrays + push @out, $h->{$sf}; + } else { +warn "====> $f $sf $o $#$sfs ", dump( $sfs ), "\n"; + push @out, $h->{$sf}->[$o]; + } + } + return @out; + } else { + # FIXME this should probably be in alphabetical order instead of hash order + values %{$h}; + } } else { $_; }