/[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 1367 by dpavlin, Thu Dec 15 21:40:37 2011 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 120  sub data_structure { Line 123  sub data_structure {
123          $load_row_coderef = $arg->{load_row_coderef};          $load_row_coderef = $arg->{load_row_coderef};
124    
125          no strict 'subs';          no strict 'subs';
126          no warnings 'redefine';          no warnings 'all';
127          eval "$arg->{rules};";          eval "$arg->{rules};";
128          die "error evaling $arg->{rules}: $@\n" if ($@);          die "error evaling $arg->{rules}: $@\n" if ($@);
129    
# Line 142  sub _set_ds { Line 145  sub _set_ds {
145          $WebPAC::Normalize::MARC::rec = $rec;          $WebPAC::Normalize::MARC::rec = $rec;
146  }  }
147    
148  =head2  =head2 _get_rec
149    
150    my $rec = _get_rec();    my $rec = _get_rec();
151    
# Line 150  sub _set_ds { Line 153  sub _set_ds {
153    
154  sub _get_rec { $rec };  sub _get_rec { $rec };
155    
156  sub rec_array {  =head2 _set_rec
157          my $d = $rec->{ $_[0] };  
158          return @$d if ref($d) eq 'ARRAY';    _set_rec( $rec );
159          die "field $_[0] not array: ",dump( $d );  
160  }  =cut
161    
162    sub _set_rec { $rec = $_[0] }
163    
164  =head2 _set_config  =head2 _set_config
165    
# Line 363  Insert new row of data into output modul Line 368  Insert new row of data into output modul
368  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
369    
370  sub row {  sub row {
371          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;
372            my $table = shift @_;
373          push @{ $out->{'_rows'} }, {@_};          push @{ $out->{'_rows'}->{$table} }, {@_};
374  }  }
375    
376    
# Line 953  sub count { Line 958  sub count {
958          return @_ . '';          return @_ . '';
959  }  }
960    
961    =head2 rec_array
962    
963    Always return field as array
964    
965      foreach my $d ( rec_array('field') ) {
966            warn $d;
967      }
968    
969    =cut
970    
971    sub rec_array {
972            my $d = $rec->{ $_[0] };
973            return @$d if ref($d) eq 'ARRAY';
974            return ($d);
975    }
976    
977  # END  # END
978  1;  1;

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

  ViewVC Help
Powered by ViewVC 1.1.26