/[webpac2]/trunk/lib/WebPAC/Normalize.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/WebPAC/Normalize.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 618 by dpavlin, Fri Aug 25 12:31:01 2006 UTC revision 631 by dpavlin, Wed Sep 6 14:25:16 2006 UTC
# Line 36  WebPAC::Normalize - describe normalisato Line 36  WebPAC::Normalize - describe normalisato
36    
37  =head1 VERSION  =head1 VERSION
38    
39  Version 0.16  Version 0.17
40    
41  =cut  =cut
42    
43  our $VERSION = '0.16';  our $VERSION = '0.17';
44    
45  =head1 SYNOPSIS  =head1 SYNOPSIS
46    
# Line 540  sub marc_compose { Line 540  sub marc_compose {
540    
541          warn "### marc_compose input subfields = ", dump(@_),$/ if ($debug > 2);          warn "### marc_compose input subfields = ", dump(@_),$/ if ($debug > 2);
542    
543            if ($#_ % 2 != 1) {
544                    die "ERROR: marc_compose",dump($f,@_)," not valid (must be even).\nDo you need to add first() or join() around some argument?\n";
545            }
546    
547          while (@_) {          while (@_) {
548                  my $sf = shift or die "marc_compose $f needs subfield";                  my $sf = shift;
549                  my $v = shift;                  my $v = shift;
550    
551                  next unless (defined($v) && $v !~ /^\s*$/);                  next unless (defined($v) && $v !~ /^\s*$/);
# Line 736  sub rec1 { Line 740  sub rec1 {
740          if (ref($rec->{$f}) eq 'ARRAY') {          if (ref($rec->{$f}) eq 'ARRAY') {
741                  return map {                  return map {
742                          if (ref($_) eq 'HASH') {                          if (ref($_) eq 'HASH') {
743                                  values %{$_};                                  my $h = $_;
744                                    if ( defined($h->{subfields}) ) {
745                                            my $sfs = delete $h->{subfields} || die "no subfields?";
746                                            my @out;
747                                            while (@$sfs) {
748                                                    my $sf = shift @$sfs;
749                                                    my $o = shift @$sfs;
750                                                    if ($o == 0 && ref( $h->{$sf} ) ne 'ARRAY' ) {
751                                                            # single element subfields are not arrays
752                                                            push @out, $h->{$sf};
753                                                    } else {
754    warn "====> $f $sf $o $#$sfs ", dump( $sfs ), "\n";
755                                                            push @out, $h->{$sf}->[$o];
756                                                    }
757                                            }
758                                            return @out;
759                                    } else {
760                                            # FIXME this should probably be in alphabetical order instead of hash order
761                                            values %{$h};
762                                    }
763                          } else {                          } else {
764                                  $_;                                  $_;
765                          }                          }

Legend:
Removed from v.618  
changed lines
  Added in v.631

  ViewVC Help
Powered by ViewVC 1.1.26