1 |
package WebPAC::Normalize; |
package WebPAC::Normalize; |
2 |
use Exporter 'import'; |
use Exporter 'import'; |
3 |
@EXPORT = qw/ |
our @EXPORT = qw/ |
4 |
_set_rec _set_lookup |
_set_ds _set_lookup |
5 |
_set_load_row |
_set_load_row |
6 |
_get_ds _clean_ds |
_get_ds _clean_ds |
7 |
_debug |
_debug |
15 |
marc_original_order |
marc_original_order |
16 |
|
|
17 |
rec1 rec2 rec |
rec1 rec2 rec |
18 |
|
frec |
19 |
regex prefix suffix surround |
regex prefix suffix surround |
20 |
first lookup join_with |
first lookup join_with |
21 |
save_into_lookup |
save_into_lookup |
24 |
|
|
25 |
get set |
get set |
26 |
count |
count |
27 |
|
|
28 |
/; |
/; |
29 |
|
|
30 |
use warnings; |
use warnings; |
38 |
# debugging warn(s) |
# debugging warn(s) |
39 |
my $debug = 0; |
my $debug = 0; |
40 |
|
|
41 |
|
use WebPAC::Normalize::ISBN; |
42 |
|
push @EXPORT, ( 'isbn_10', 'isbn_13' ); |
43 |
|
|
44 |
=head1 NAME |
=head1 NAME |
45 |
|
|
47 |
|
|
48 |
=cut |
=cut |
49 |
|
|
50 |
our $VERSION = '0.31'; |
our $VERSION = '0.32'; |
51 |
|
|
52 |
=head1 SYNOPSIS |
=head1 SYNOPSIS |
53 |
|
|
79 |
marc_encoding => 'utf-8', |
marc_encoding => 'utf-8', |
80 |
config => $config, |
config => $config, |
81 |
load_row_coderef => sub { |
load_row_coderef => sub { |
82 |
my ($database,$input,$mfn) = shift; |
my ($database,$input,$mfn) = @_; |
83 |
$store->load_row( database => $database, input => $input, id => $mfn ); |
$store->load_row( database => $database, input => $input, id => $mfn ); |
84 |
}, |
}, |
85 |
); |
); |
107 |
|
|
108 |
no strict 'subs'; |
no strict 'subs'; |
109 |
_set_lookup( $arg->{lookup} ) if defined($arg->{lookup}); |
_set_lookup( $arg->{lookup} ) if defined($arg->{lookup}); |
110 |
_set_rec( $arg->{row} ); |
_set_ds( $arg->{row} ); |
111 |
_set_config( $arg->{config} ) if defined($arg->{config}); |
_set_config( $arg->{config} ) if defined($arg->{config}); |
112 |
_clean_ds( %{ $arg } ); |
_clean_ds( %{ $arg } ); |
113 |
$load_row_coderef = $arg->{load_row_coderef}; |
$load_row_coderef = $arg->{load_row_coderef}; |
114 |
|
|
|
# FIXME load this conditionally |
|
|
use WebPAC::Normalize::ISBN; |
|
|
|
|
115 |
eval "$arg->{rules}"; |
eval "$arg->{rules}"; |
116 |
die "error evaling $arg->{rules}: $@\n" if ($@); |
die "error evaling $arg->{rules}: $@\n" if ($@); |
117 |
|
|
118 |
return _get_ds(); |
return _get_ds(); |
119 |
} |
} |
120 |
|
|
121 |
=head2 _set_rec |
=head2 _set_ds |
122 |
|
|
123 |
Set current record hash |
Set current record hash |
124 |
|
|
125 |
_set_rec( $rec ); |
_set_ds( $rec ); |
126 |
|
|
127 |
=cut |
=cut |
128 |
|
|
129 |
my $rec; |
my $rec; |
130 |
|
|
131 |
sub _set_rec { |
sub _set_ds { |
132 |
$rec = shift or die "no record hash"; |
$rec = shift or die "no record hash"; |
133 |
} |
} |
134 |
|
|
172 |
my ($marc_record_offset, $marc_fetch_offset) = (0, 0); |
my ($marc_record_offset, $marc_fetch_offset) = (0, 0); |
173 |
|
|
174 |
sub _get_ds { |
sub _get_ds { |
175 |
|
#warn "## out = ",dump($out); |
176 |
return $out; |
return $out; |
177 |
} |
} |
178 |
|
|
999 |
|
|
1000 |
=cut |
=cut |
1001 |
|
|
1002 |
|
sub frec { |
1003 |
|
my @out = rec(@_); |
1004 |
|
warn "rec(",dump(@_),") has more than one return value, ignoring\n" if $#out > 0; |
1005 |
|
return shift @out; |
1006 |
|
} |
1007 |
|
|
1008 |
sub rec { |
sub rec { |
1009 |
my @out; |
my @out; |
1010 |
if ($#_ == 0) { |
if ($#_ == 0) { |