--- trunk/lib/WebPAC/Normalize.pm 2009/05/29 20:55:54 1206 +++ trunk/lib/WebPAC/Normalize.pm 2013/08/22 08:16:28 1373 @@ -123,9 +123,9 @@ $load_row_coderef = $arg->{load_row_coderef}; no strict 'subs'; - no warnings 'redefine'; + no warnings 'all'; eval "$arg->{rules};"; - die "error evaling $arg->{rules}: $@\n" if ($@); + die "error evaling [$@] using rules " . $arg->{rules} . "\n" if ($@); return _get_ds(); } @@ -145,7 +145,7 @@ $WebPAC::Normalize::MARC::rec = $rec; } -=head2 +=head2 _get_rec my $rec = _get_rec(); @@ -153,11 +153,13 @@ sub _get_rec { $rec }; -sub rec_array { - my $d = $rec->{ $_[0] }; - return @$d if ref($d) eq 'ARRAY'; - die "field $_[0] not array: ",dump( $d ); -} +=head2 _set_rec + + _set_rec( $rec ); + +=cut + +sub _set_rec { $rec = $_[0] } =head2 _set_config @@ -366,9 +368,9 @@ use Data::Dump qw/dump/; sub row { - die "array doesn't have even number of elements but $#_: ",dump( @_ ) if $#_ % 2 != 1; - - push @{ $out->{'_rows'} }, {@_}; + die "array doesn't have odd number of elements but $#_: ",dump( @_ ) if $#_ % 2 == 1; + my $table = shift @_; + push @{ $out->{'_rows'}->{$table} }, {@_}; } @@ -956,5 +958,21 @@ return @_ . ''; } +=head2 rec_array + +Always return field as array + + foreach my $d ( rec_array('field') ) { + warn $d; + } + +=cut + +sub rec_array { + my $d = $rec->{ $_[0] }; + return @$d if ref($d) eq 'ARRAY'; + return ($d); +} + # END 1;