--- trunk/lib/WebPAC/Normalize.pm 2007/11/07 11:54:34 1013 +++ trunk/lib/WebPAC/Normalize.pm 2007/11/08 17:19:50 1015 @@ -16,7 +16,7 @@ marc_template rec1 rec2 rec - frec + frec frec_eq frec_ne regex prefix suffix surround first lookup join_with save_into_lookup @@ -48,7 +48,7 @@ =cut -our $VERSION = '0.33'; +our $VERSION = '0.34'; =head1 SYNOPSIS @@ -1168,6 +1168,39 @@ return shift @out; } +=head2 frec_eq + +=head2 frec_ne + +Check if first values from two fields are same or different + + if ( frec_eq( 900 => 'a', 910 => 'c' ) ) { + # values are same + } else { + # values are different + } + +Strictly speaking C and C wouldn't be needed if you +could write something like: + + if ( frec( '900','a' ) eq frec( '910','c' ) ) { + # yada tada + } + +but you can't since our parser L will remove all whitespaces +in order to parse text and create invalid function C. + +=cut + +sub frec_eq { + my ( $f1,$sf1, $f2, $sf2 ) = @_; + return (rec( $f1, $sf1 ))[0] eq (rec( $f2, $sf2 ))[0]; +} + +sub frec_ne { + return ! frec_eq( @_ ); +} + =head2 regex Apply regex to some or all values