--- trunk/lib/WebPAC/Normalize.pm 2009/05/29 20:55:54 1206 +++ trunk/lib/WebPAC/Normalize.pm 2011/04/21 17:10:04 1364 @@ -123,7 +123,7 @@ $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 ($@); @@ -153,12 +153,6 @@ 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_config Set current config hash @@ -366,9 +360,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 +950,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;