--- trunk/lib/WebPAC/Normalize.pm 2007/11/04 11:12:38 983 +++ trunk/lib/WebPAC/Normalize.pm 2007/11/07 09:19:29 1012 @@ -2,7 +2,6 @@ use Exporter 'import'; our @EXPORT = qw/ _set_ds _set_lookup - get_ds _set_load_row _get_ds _clean_ds _debug @@ -106,14 +105,15 @@ die "need row argument" unless ($arg->{row}); die "need normalisation argument" unless ($arg->{rules}); - no strict 'subs'; _set_lookup( $arg->{lookup} ) if defined($arg->{lookup}); _set_ds( $arg->{row} ); _set_config( $arg->{config} ) if defined($arg->{config}); _clean_ds( %{ $arg } ); $load_row_coderef = $arg->{load_row_coderef}; - eval "$arg->{rules}"; + no strict 'subs'; + no warnings 'redefine'; + eval "$arg->{rules};"; die "error evaling $arg->{rules}: $@\n" if ($@); return _get_ds(); @@ -133,18 +133,6 @@ $rec = shift or die "no record hash"; } -=head2 get_ds - -Access to original record from input module - - my $ds = get_rec; - -=cut - -sub get_ds { - return $rec; -} - =head2 _set_config Set current config hash @@ -1012,12 +1000,6 @@ =cut -sub frec { - my @out = rec(@_); - warn "rec(",dump(@_),") has more than one return value, ignoring\n" if $#out > 0; - return shift @out; -} - sub rec { my @out; if ($#_ == 0) { @@ -1034,6 +1016,21 @@ } } +=head2 frec + +Returns first value from field + + $v = frec('200'); + $v = frec('200','a'); + +=cut + +sub frec { + my @out = rec(@_); + warn "rec(",dump(@_),") has more than one return value, ignoring\n" if $#out > 0; + return shift @out; +} + =head2 regex Apply regex to some or all values