r1896@llin: dpavlin | 2009-05-29 22:32:12 +0200
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 29 May 2009 20:32:13 +0000 (20:32 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 29 May 2009 20:32:13 +0000 (20:32 +0000)
 added rec_array and row and small example how to create
 multiple rows from single record in input file

git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@1205 07558da8-63fa-0310-ba24-9fe276d99e06

conf/isi/cu-au-count.pl [new file with mode: 0644]
lib/WebPAC/Normalize.pm

diff --git a/conf/isi/cu-au-count.pl b/conf/isi/cu-au-count.pl
new file mode 100644 (file)
index 0000000..03ee22d
--- /dev/null
@@ -0,0 +1,9 @@
+
+foreach my $cr ( rec_array 'CR' ) {
+       foreach my $au ( rec_array 'AU' ) {
+               row(
+                       cited => $cr->{author},
+                       by => $au,
+               );
+       }
+}
index 17e1832..d753370 100644 (file)
@@ -150,6 +150,12 @@ sub _set_ds {
 
 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
@@ -346,6 +352,22 @@ Insert into lists which will be automatically sorted
 
 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 even number of elements but $#_: ",dump( @_ ) if $#_ % 2 != 1;
+
+       push @{ $out->{'_rows'} }, {@_};
+}
+
 
 =head1 Functions to extract data from input