/[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 1015 by dpavlin, Thu Nov 8 17:19:50 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 1168  sub frec { Line 1168  sub frec {
1168          return shift @out;          return shift @out;
1169  }  }
1170    
1171    =head2 frec_eq
1172    
1173    =head2 frec_ne
1174    
1175    Check if first values from two fields are same or different
1176    
1177      if ( frec_eq( 900 => 'a', 910 => 'c' ) ) {
1178            # values are same
1179      } else {
1180        # values are different
1181      }
1182    
1183    Strictly speaking C<frec_eq> and C<frec_ne> wouldn't be needed if you
1184    could write something like:
1185    
1186      if ( frec( '900','a' ) eq frec( '910','c' ) ) {
1187            # yada tada
1188      }
1189    
1190    but you can't since our parser L<WebPAC::Parser> will remove all whitespaces
1191    in order to parse text and create invalid function C<eqfrec>.
1192    
1193    =cut
1194    
1195    sub frec_eq {
1196            my ( $f1,$sf1, $f2, $sf2 ) = @_;
1197            return (rec( $f1, $sf1 ))[0] eq (rec( $f2, $sf2 ))[0];
1198    }
1199    
1200    sub frec_ne {
1201            return ! frec_eq( @_ );
1202    }
1203    
1204  =head2 regex  =head2 regex
1205    
1206  Apply regex to some or all values  Apply regex to some or all values

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

  ViewVC Help
Powered by ViewVC 1.1.26