--- trunk/lib/WebPAC/Normalize.pm 2009/05/29 20:32:13 1205 +++ trunk/lib/WebPAC/Normalize.pm 2009/06/02 13:17:24 1216 @@ -21,6 +21,9 @@ get set count + row + rec_array + /; use warnings; @@ -150,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 @@ -363,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} }, {@_}; } @@ -953,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;