/[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 1013 by dpavlin, Wed Nov 7 11:54:34 2007 UTC revision 1016 by dpavlin, Thu Nov 8 17:29:03 2007 UTC
# Line 16  our @EXPORT = qw/ Line 16  our @EXPORT = qw/
16          marc_template          marc_template
17    
18          rec1 rec2 rec          rec1 rec2 rec
19          frec          frec frec_eq frec_ne
20          regex prefix suffix surround          regex prefix suffix surround
21          first lookup join_with          first lookup join_with
22          save_into_lookup          save_into_lookup
# Line 48  WebPAC::Normalize - describe normalisato Line 48  WebPAC::Normalize - describe normalisato
48    
49  =cut  =cut
50    
51  our $VERSION = '0.33';  our $VERSION = '0.34';
52    
53  =head1 SYNOPSIS  =head1 SYNOPSIS
54    
# Line 984  sub marc_template { Line 984  sub marc_template {
984                          my ( $sf, $nr ) = @$sf;                          my ( $sf, $nr ) = @$sf;
985                          my $v = $fill_in->{$sf}->[$nr] || die "can't find fill_in $sf/$nr";                          my $v = $fill_in->{$sf}->[$nr] || die "can't find fill_in $sf/$nr";
986                          warn "++ $sf/$nr |$v|\n";                          warn "++ $sf/$nr |$v|\n";
987                          push @$m, [ $sf, $v ];                          push @$m, ( $sf, $v );
988                  }                  }
989    
990                  warn "#### >>>> created marc: ", dump( $m );                  warn "#### >>>> created marc: ", dump( $m );
# Line 993  sub marc_template { Line 993  sub marc_template {
993          }          }
994    
995          warn "### marc_template produced: ",dump( @marc_out );          warn "### marc_template produced: ",dump( @marc_out );
996          return @marc_out;  
997            foreach my $marc ( @marc_out ) {
998                    warn "+++ ",dump( $marc );
999                    push @{ $marc_record->[ $marc_record_offset ] }, $marc;
1000            }
1001  }  }
1002    
1003  =head2 marc_count  =head2 marc_count
# Line 1168  sub frec { Line 1172  sub frec {
1172          return shift @out;          return shift @out;
1173  }  }
1174    
1175    =head2 frec_eq
1176    
1177    =head2 frec_ne
1178    
1179    Check if first values from two fields are same or different
1180    
1181      if ( frec_eq( 900 => 'a', 910 => 'c' ) ) {
1182            # values are same
1183      } else {
1184        # values are different
1185      }
1186    
1187    Strictly speaking C<frec_eq> and C<frec_ne> wouldn't be needed if you
1188    could write something like:
1189    
1190      if ( frec( '900','a' ) eq frec( '910','c' ) ) {
1191            # yada tada
1192      }
1193    
1194    but you can't since our parser L<WebPAC::Parser> will remove all whitespaces
1195    in order to parse text and create invalid function C<eqfrec>.
1196    
1197    =cut
1198    
1199    sub frec_eq {
1200            my ( $f1,$sf1, $f2, $sf2 ) = @_;
1201            return (rec( $f1, $sf1 ))[0] eq (rec( $f2, $sf2 ))[0];
1202    }
1203    
1204    sub frec_ne {
1205            return ! frec_eq( @_ );
1206    }
1207    
1208  =head2 regex  =head2 regex
1209    
1210  Apply regex to some or all values  Apply regex to some or all values

Legend:
Removed from v.1013  
changed lines
  Added in v.1016

  ViewVC Help
Powered by ViewVC 1.1.26