--- trunk/lib/WebPAC/Normalize.pm 2007/10/30 17:40:13 912 +++ trunk/lib/WebPAC/Normalize.pm 2007/11/03 13:33:19 980 @@ -1,13 +1,13 @@ package WebPAC::Normalize; use Exporter 'import'; -@EXPORT = qw/ +our @EXPORT = qw/ _set_rec _set_lookup _set_load_row _get_ds _clean_ds _debug _pack_subfields_hash - search_display search display + search_display search display sorted marc marc_indicators marc_repeatable_subfield marc_compose marc_leader marc_fixed @@ -15,6 +15,7 @@ marc_original_order rec1 rec2 rec + frec regex prefix suffix surround first lookup join_with save_into_lookup @@ -23,6 +24,7 @@ get set count + /; use warnings; @@ -36,18 +38,16 @@ # debugging warn(s) my $debug = 0; +use WebPAC::Normalize::ISBN; +push @EXPORT, ( 'isbn_10', 'isbn_13' ); =head1 NAME WebPAC::Normalize - describe normalisaton rules using sets -=head1 VERSION - -Version 0.30 - =cut -our $VERSION = '0.30'; +our $VERSION = '0.31'; =head1 SYNOPSIS @@ -79,7 +79,7 @@ marc_encoding => 'utf-8', config => $config, load_row_coderef => sub { - my ($database,$input,$mfn) = shift; + my ($database,$input,$mfn) = @_; $store->load_row( database => $database, input => $input, id => $mfn ); }, ); @@ -172,6 +172,9 @@ my ($marc_record_offset, $marc_fetch_offset) = (0, 0); sub _get_ds { + +warn "## out = ",dump($out); + return $out; } @@ -460,6 +463,16 @@ $out->{$name}->{display} = \@o; } +=head2 tag + +Old name for L, but supported + +=cut + +sub tag { + search_display( @_ ); +} + =head2 display Define output just for I @@ -468,13 +481,16 @@ =cut -sub display { - my $name = shift or die "display needs name as first argument"; +sub _field { + my $type = shift or confess "need type -- BUG?"; + my $name = shift or confess "needs name as first argument"; my @o = grep { defined($_) && $_ ne '' } @_; return unless (@o); - $out->{$name}->{display} = \@o; + $out->{$name}->{$type} = \@o; } +sub display { _field( 'display', @_ ) } + =head2 search Prepare values just for I @@ -483,12 +499,18 @@ =cut -sub search { - my $name = shift or die "search needs name as first argument"; - my @o = grep { defined($_) && $_ ne '' } @_; - return unless (@o); - $out->{$name}->{search} = \@o; -} +sub search { _field( 'search', @_ ) } + +=head2 sorted + +Insert into lists which will be automatically sorted + + sorted('Title', rec('200','a') ); + +=cut + +sub sorted { _field( 'sorted', @_ ) } + =head2 marc_leader @@ -979,6 +1001,12 @@ =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) {