in reply to Re^5: Saving sql results to an array all rows?
in thread Saving sql results to an array all rows?
Here are the results that I am getting with the code shown above looks like I am just getting array refs??foreach my $line (@lines) { $sth->execute($line, $line) or die "Can't execute SQL statemen +t: $DBI::errstr\n"; my @all_rows; while ( my $ref = $sth->fetchrow_arrayref()) { push(@all_rows, $ref ); } my @sorted = map { $_->[0] } sort { $a->[1] <=> $b->[1] || $a->[2] <=> $b->[2] || $a->[3] <=> $b->[3] || $a->[4] <=> $b->[4] } map { [$_, split(/\./, (split /\s+/, $_)[1] ) ] } @all_rows; my @all_rows1 = map { [ split( /\s+/, $_ ) ] } @all_rows; my @sorted1 = map { join( ' ', @{ $_->[0] } ) } sort { $a->[1] <=> $b->[1] || $a->[2] <=> $b->[2] || $a->[3] <=> $b->[3] || $a->[4] <=> $b->[4] } map { [$_, split(/\./, $$_[1] ) ] } @all_rows1; print Dumper @sorted1; }
Here is what the results look like if I used the code which I posted in the previous post(keep in mind that the results that I am getting with that code are correct/accurate) but the way it gets printed the sort won't do anything cause the sort is looking for data the look like the data in your @lines example that you used in your sort map.$VAR1 = 'ARRAY(0x94db6f8)'; $VAR2 = 'ARRAY(0x94db6f8)'; $VAR3 = 'ARRAY(0x94db6f8)'; $VAR1 = 'ARRAY(0x94db6f8)'; $VAR2 = 'ARRAY(0x94db6f8)'; $VAR3 = 'ARRAY(0x94db6f8)'; $VAR4 = 'ARRAY(0x94db6f8)'; $VAR5 = 'ARRAY(0x94db6f8)'; $VAR6 = 'ARRAY(0x94db6f8)'; $VAR1 = 'ARRAY(0x94db6f8)'; $VAR1 = 'ARRAY(0x94db6f8)'; $VAR1 = 'ARRAY(0x94db6f8)';
$VAR1 = [ 'data', 'data', 'data', 'data', 'data', ]; $VAR2 = [ 'data', 'etc..etc',
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Saving sql results to an array all rows?
by Krambambuli (Curate) on Aug 20, 2008 at 13:07 UTC | |
by learningperl01 (Beadle) on Aug 20, 2008 at 16:41 UTC | |
by Cristoforo (Curate) on Aug 20, 2008 at 20:45 UTC | |
by learningperl01 (Beadle) on Aug 21, 2008 at 15:21 UTC | |
by Cristoforo (Curate) on Aug 21, 2008 at 16:10 UTC | |
| |
by Krambambuli (Curate) on Aug 20, 2008 at 17:06 UTC |