/[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 973 by dpavlin, Fri Nov 2 14:59:12 2007 UTC revision 983 by dpavlin, Sun Nov 4 11:12:38 2007 UTC
# Line 1  Line 1 
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            get_ds
6          _set_load_row          _set_load_row
7          _get_ds _clean_ds          _get_ds _clean_ds
8          _debug          _debug
# Line 15  use Exporter 'import'; Line 16  use Exporter 'import';
16          marc_original_order          marc_original_order
17    
18          rec1 rec2 rec          rec1 rec2 rec
19            frec
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 23  use Exporter 'import'; Line 25  use Exporter 'import';
25    
26          get set          get set
27          count          count
28    
29  /;  /;
30    
31  use warnings;  use warnings;
# Line 36  use Carp qw/confess/; Line 39  use Carp qw/confess/;
39  # debugging warn(s)  # debugging warn(s)
40  my $debug = 0;  my $debug = 0;
41    
42    use WebPAC::Normalize::ISBN;
43    push @EXPORT, ( 'isbn_10', 'isbn_13' );
44    
45  =head1 NAME  =head1 NAME
46    
# Line 43  WebPAC::Normalize - describe normalisato Line 48  WebPAC::Normalize - describe normalisato
48    
49  =cut  =cut
50    
51  our $VERSION = '0.31';  our $VERSION = '0.32';
52    
53  =head1 SYNOPSIS  =head1 SYNOPSIS
54    
# Line 75  Return data structure Line 80  Return data structure
80          marc_encoding => 'utf-8',          marc_encoding => 'utf-8',
81          config => $config,          config => $config,
82          load_row_coderef => sub {          load_row_coderef => sub {
83                  my ($database,$input,$mfn) = shift;                  my ($database,$input,$mfn) = @_;
84                  $store->load_row( database => $database, input => $input, id => $mfn );                  $store->load_row( database => $database, input => $input, id => $mfn );
85          },          },
86    );    );
# Line 103  sub data_structure { Line 108  sub data_structure {
108    
109          no strict 'subs';          no strict 'subs';
110          _set_lookup( $arg->{lookup} ) if defined($arg->{lookup});          _set_lookup( $arg->{lookup} ) if defined($arg->{lookup});
111          _set_rec( $arg->{row} );          _set_ds( $arg->{row} );
112          _set_config( $arg->{config} ) if defined($arg->{config});          _set_config( $arg->{config} ) if defined($arg->{config});
113          _clean_ds( %{ $arg } );          _clean_ds( %{ $arg } );
114          $load_row_coderef = $arg->{load_row_coderef};          $load_row_coderef = $arg->{load_row_coderef};
115    
         # FIXME load this conditionally  
         use WebPAC::Normalize::ISBN;  
   
116          eval "$arg->{rules}";          eval "$arg->{rules}";
117          die "error evaling $arg->{rules}: $@\n" if ($@);          die "error evaling $arg->{rules}: $@\n" if ($@);
118    
119          return _get_ds();          return _get_ds();
120  }  }
121    
122  =head2 _set_rec  =head2 _set_ds
123    
124  Set current record hash  Set current record hash
125    
126    _set_rec( $rec );    _set_ds( $rec );
127    
128  =cut  =cut
129    
130  my $rec;  my $rec;
131    
132  sub _set_rec {  sub _set_ds {
133          $rec = shift or die "no record hash";          $rec = shift or die "no record hash";
134  }  }
135    
136    =head2 get_ds
137    
138    Access to original record from input module
139    
140      my $ds = get_rec;
141    
142    =cut
143    
144    sub get_ds {
145            return $rec;
146    }
147    
148  =head2 _set_config  =head2 _set_config
149    
150  Set current config hash  Set current config hash
# Line 171  my ($out, $marc_record, $marc_encoding, Line 185  my ($out, $marc_record, $marc_encoding,
185  my ($marc_record_offset, $marc_fetch_offset) = (0, 0);  my ($marc_record_offset, $marc_fetch_offset) = (0, 0);
186    
187  sub _get_ds {  sub _get_ds {
188    #warn "## out = ",dump($out);
189          return $out;          return $out;
190  }  }
191    
# Line 997  return scalar, not array. Line 1012  return scalar, not array.
1012    
1013  =cut  =cut
1014    
1015    sub frec {
1016            my @out = rec(@_);
1017            warn "rec(",dump(@_),") has more than one return value, ignoring\n" if $#out > 0;
1018            return shift @out;
1019    }
1020    
1021  sub rec {  sub rec {
1022          my @out;          my @out;
1023          if ($#_ == 0) {          if ($#_ == 0) {

Legend:
Removed from v.973  
changed lines
  Added in v.983

  ViewVC Help
Powered by ViewVC 1.1.26