--- trunk/lib/WebPAC/Normalize.pm 2006/09/06 21:09:30 642 +++ trunk/lib/WebPAC/Normalize.pm 2006/09/11 14:28:56 668 @@ -24,7 +24,6 @@ #use base qw/WebPAC::Common/; use Data::Dump qw/dump/; -use Encode qw/from_to/; use Storable qw/dclone/; # debugging warn(s) @@ -37,11 +36,11 @@ =head1 VERSION -Version 0.17 +Version 0.19 =cut -our $VERSION = '0.17'; +our $VERSION = '0.19'; =head1 SYNOPSIS @@ -470,7 +469,6 @@ foreach (@_) { my $v = $_; # make var read-write for Encode next unless (defined($v) && $v !~ /^\s*$/); - from_to($v, 'iso-8859-2', $marc_encoding) if ($marc_encoding); my ($i1,$i2) = defined($marc_indicators->{$f}) ? @{ $marc_indicators->{$f} } : (' ',' '); if (defined $sf) { push @{ $marc_record->[ $marc_record_offset ] }, [ $f, $i1, $i2, $sf => $v ]; @@ -550,7 +548,6 @@ my $v = shift; next unless (defined($v) && $v !~ /^\s*$/); - from_to($v, 'iso-8859-2', $marc_encoding) if ($marc_encoding); warn "## ++ marc_compose($f,$sf,$v) ", dump( $m ),$/ if ($debug > 1); if ($sf ne '+') { push @$m, ( $sf, $v ); @@ -735,7 +732,6 @@ my ($h,$include_subfields) = @_; - if ( defined($h->{subfields}) ) { my $sfs = delete $h->{subfields} || die "no subfields?"; my @out; @@ -745,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 (sort 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}; + } } }