/[webpac2]/trunk/lib/WebPAC/Normalize.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/WebPAC/Normalize.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1205 by dpavlin, Fri May 29 20:32:13 2009 UTC revision 1216 by dpavlin, Tue Jun 2 13:17:24 2009 UTC
# Line 21  our @EXPORT = qw/ Line 21  our @EXPORT = qw/
21          get set          get set
22          count          count
23    
24            row
25            rec_array
26    
27  /;  /;
28    
29  use warnings;  use warnings;
# Line 150  sub _set_ds { Line 153  sub _set_ds {
153    
154  sub _get_rec { $rec };  sub _get_rec { $rec };
155    
 sub rec_array {  
         my $d = $rec->{ $_[0] };  
         return @$d if ref($d) eq 'ARRAY';  
         die "field $_[0] not array: ",dump( $d );  
 }  
   
156  =head2 _set_config  =head2 _set_config
157    
158  Set current config hash  Set current config hash
# Line 363  Insert new row of data into output modul Line 360  Insert new row of data into output modul
360  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
361    
362  sub row {  sub row {
363          die "array doesn't have even number of elements but $#_: ",dump( @_ ) if $#_ % 2 != 1;          die "array doesn't have odd number of elements but $#_: ",dump( @_ ) if $#_ % 2 == 1;
364            my $table = shift @_;
365          push @{ $out->{'_rows'} }, {@_};          push @{ $out->{'_rows'}->{$table} }, {@_};
366  }  }
367    
368    
# Line 953  sub count { Line 950  sub count {
950          return @_ . '';          return @_ . '';
951  }  }
952    
953    =head2 rec_array
954    
955    Always return field as array
956    
957      foreach my $d ( rec_array('field') ) {
958            warn $d;
959      }
960    
961    =cut
962    
963    sub rec_array {
964            my $d = $rec->{ $_[0] };
965            return @$d if ref($d) eq 'ARRAY';
966            return ($d);
967    }
968    
969  # END  # END
970  1;  1;

Legend:
Removed from v.1205  
changed lines
  Added in v.1216

  ViewVC Help
Powered by ViewVC 1.1.26