/[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 815 by dpavlin, Mon Apr 2 17:20:01 2007 UTC revision 819 by dpavlin, Wed Apr 11 10:09:34 2007 UTC
# Line 42  WebPAC::Normalize - describe normalisato Line 42  WebPAC::Normalize - describe normalisato
42    
43  =head1 VERSION  =head1 VERSION
44    
45  Version 0.28  Version 0.29
46    
47  =cut  =cut
48    
49  our $VERSION = '0.28';  our $VERSION = '0.29';
50    
51  =head1 SYNOPSIS  =head1 SYNOPSIS
52    
# Line 542  sub marc_fixed { Line 542  sub marc_fixed {
542                          my $old = $_->[1];                          my $old = $_->[1];
543                          if (length($old) < $pos) {                          if (length($old) < $pos) {
544                                  $_->[1] .= ' ' x ( $pos - length($old) ) . $val;                                  $_->[1] .= ' ' x ( $pos - length($old) ) . $val;
545                                  warn "## marc_fixed($f,$pos,'$val') append '$old' -> '$_->[1]'\n";                                  warn "## marc_fixed($f,$pos,'$val') append '$old' -> '$_->[1]'\n" if ($debug > 1);
546                          } else {                          } else {
547                                  $_->[1] = substr($old, 0, $pos) . $val . substr($old, $pos + length($val));                                  $_->[1] = substr($old, 0, $pos) . $val . substr($old, $pos + length($val));
548                                  warn "## marc_fixed($f,$pos,'$val') update '$old' -> '$_->[1]'\n";                                  warn "## marc_fixed($f,$pos,'$val') update '$old' -> '$_->[1]'\n" if ($debug > 1);
549                          }                          }
550                          $update++;                          $update++;
551                  }                  }
# Line 554  sub marc_fixed { Line 554  sub marc_fixed {
554          if (! $update) {          if (! $update) {
555                  my $v = ' ' x $pos . $val;                  my $v = ' ' x $pos . $val;
556                  push @{ $marc_record->[ $marc_record_offset ] }, [ $f, $v ];                  push @{ $marc_record->[ $marc_record_offset ] }, [ $f, $v ];
557                  warn "## marc_fixed($f,$pos,'val') created '$v'\n";                  warn "## marc_fixed($f,$pos,'val') created '$v'\n" if ($debug > 1);
558          }          }
559  }  }
560    
# Line 1021  Prefix all values with a string Line 1021  Prefix all values with a string
1021  =cut  =cut
1022    
1023  sub prefix {  sub prefix {
1024          my $p = shift or return;          my $p = shift;
1025            return @_ unless defined( $p );
1026          return map { $p . $_ } grep { defined($_) } @_;          return map { $p . $_ } grep { defined($_) } @_;
1027  }  }
1028    
# Line 1034  suffix all values with a string Line 1035  suffix all values with a string
1035  =cut  =cut
1036    
1037  sub suffix {  sub suffix {
1038          my $s = shift or die "suffix needs string as first argument";          my $s = shift;
1039            return @_ unless defined( $s );
1040          return map { $_ . $s } grep { defined($_) } @_;          return map { $_ . $s } grep { defined($_) } @_;
1041  }  }
1042    
# Line 1047  surround all values with a two strings Line 1049  surround all values with a two strings
1049  =cut  =cut
1050    
1051  sub surround {  sub surround {
1052          my $p = shift or die "surround need prefix as first argument";          my $p = shift;
1053          my $s = shift or die "surround needs suffix as second argument";          my $s = shift;
1054            $p = '' unless defined( $p );
1055            $s = '' unless defined( $s );
1056          return map { $p . $_ . $s } grep { defined($_) } @_;          return map { $p . $_ . $s } grep { defined($_) } @_;
1057  }  }
1058    

Legend:
Removed from v.815  
changed lines
  Added in v.819

  ViewVC Help
Powered by ViewVC 1.1.26