21 |
get set |
get set |
22 |
count |
count |
23 |
|
|
24 |
|
row |
25 |
|
rec_array |
26 |
|
|
27 |
/; |
/; |
28 |
|
|
29 |
use warnings; |
use warnings; |
50 |
marc_template |
marc_template |
51 |
/); |
/); |
52 |
|
|
53 |
|
use Storable qw/dclone/; |
54 |
|
|
55 |
=head1 NAME |
=head1 NAME |
56 |
|
|
57 |
WebPAC::Normalize - describe normalisaton rules using sets |
WebPAC::Normalize - describe normalisaton rules using sets |
123 |
$load_row_coderef = $arg->{load_row_coderef}; |
$load_row_coderef = $arg->{load_row_coderef}; |
124 |
|
|
125 |
no strict 'subs'; |
no strict 'subs'; |
126 |
no warnings 'redefine'; |
no warnings 'all'; |
127 |
eval "$arg->{rules};"; |
eval "$arg->{rules};"; |
128 |
die "error evaling $arg->{rules}: $@\n" if ($@); |
die "error evaling [$@] using rules " . $arg->{rules} . "\n" if ($@); |
129 |
|
|
130 |
return _get_ds(); |
return _get_ds(); |
131 |
} |
} |
145 |
$WebPAC::Normalize::MARC::rec = $rec; |
$WebPAC::Normalize::MARC::rec = $rec; |
146 |
} |
} |
147 |
|
|
148 |
=head2 |
=head2 _get_rec |
149 |
|
|
150 |
my $rec = _get_rec(); |
my $rec = _get_rec(); |
151 |
|
|
153 |
|
|
154 |
sub _get_rec { $rec }; |
sub _get_rec { $rec }; |
155 |
|
|
156 |
|
=head2 _set_rec |
157 |
|
|
158 |
|
_set_rec( $rec ); |
159 |
|
|
160 |
|
=cut |
161 |
|
|
162 |
|
sub _set_rec { $rec = $_[0] } |
163 |
|
|
164 |
=head2 _set_config |
=head2 _set_config |
165 |
|
|
166 |
Set current config hash |
Set current config hash |
357 |
|
|
358 |
sub sorted { to( 'sorted', @_ ) } |
sub sorted { to( 'sorted', @_ ) } |
359 |
|
|
360 |
|
=head2 row |
361 |
|
|
362 |
|
Insert new row of data into output module |
363 |
|
|
364 |
|
row( column => 'foo', column2 => 'bar' ); |
365 |
|
|
366 |
|
=cut |
367 |
|
|
368 |
|
use Data::Dump qw/dump/; |
369 |
|
|
370 |
|
sub row { |
371 |
|
die "array doesn't have odd number of elements but $#_: ",dump( @_ ) if $#_ % 2 == 1; |
372 |
|
my $table = shift @_; |
373 |
|
push @{ $out->{'_rows'}->{$table} }, {@_}; |
374 |
|
} |
375 |
|
|
376 |
|
|
377 |
=head1 Functions to extract data from input |
=head1 Functions to extract data from input |
378 |
|
|
393 |
|
|
394 |
warn "## _pack_subfields_hash( ",dump(@_), " )\n" if ($debug > 1); |
warn "## _pack_subfields_hash( ",dump(@_), " )\n" if ($debug > 1); |
395 |
|
|
396 |
my ($h,$include_subfields) = @_; |
my ($hash,$include_subfields) = @_; |
397 |
|
|
398 |
# sanity and ease of use |
# sanity and ease of use |
399 |
return $h if (ref($h) ne 'HASH'); |
return $hash if (ref($hash) ne 'HASH'); |
400 |
|
|
401 |
|
my $h = dclone( $hash ); |
402 |
|
|
403 |
if ( defined($h->{subfields}) ) { |
if ( defined($h->{subfields}) ) { |
404 |
my $sfs = delete $h->{subfields} || die "no subfields?"; |
my $sfs = delete $h->{subfields} || die "no subfields?"; |
958 |
return @_ . ''; |
return @_ . ''; |
959 |
} |
} |
960 |
|
|
961 |
|
=head2 rec_array |
962 |
|
|
963 |
|
Always return field as array |
964 |
|
|
965 |
|
foreach my $d ( rec_array('field') ) { |
966 |
|
warn $d; |
967 |
|
} |
968 |
|
|
969 |
|
=cut |
970 |
|
|
971 |
|
sub rec_array { |
972 |
|
my $d = $rec->{ $_[0] }; |
973 |
|
return @$d if ref($d) eq 'ARRAY'; |
974 |
|
return ($d); |
975 |
|
} |
976 |
|
|
977 |
# END |
# END |
978 |
1; |
1; |