--- trunk/lib/WebPAC/Normalize.pm 2008/10/26 15:57:37 1118 +++ trunk/lib/WebPAC/Normalize.pm 2009/06/02 13:14:59 1214 @@ -21,6 +21,9 @@ get set count + row + rec_array + /; use warnings; @@ -346,6 +349,22 @@ sub sorted { to( 'sorted', @_ ) } +=head2 row + +Insert new row of data into output module + + row( column => 'foo', column2 => 'bar' ); + +=cut + +use Data::Dump qw/dump/; + +sub row { + die "array doesn't have odd number of elements but $#_: ",dump( @_ ) if $#_ % 2 == 1; + my $table = shift @_; + push @{ $out->{'_rows'}->{$table} }, {@_}; +} + =head1 Functions to extract data from input @@ -931,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;