in reply to Multidimensional arrays and DB columns
If I understand you correctly, I think you might be better off returning a reference to an array of arrays so you can keep each row's id, name and perm separate. Something like (not tested)
... my $raResults = []; while( $raRow = $projects->fetchrow_arrayref() ) { push @$raResults, [ @{ $raRow }[ 0, 1, 2 ] ]; } return $raResults; ...
and later print each set of three items, locally setting the list separator (see perlvar) to a tab
foreach my $raRowPick ( @$raResults ) { print do{ local $" = qq{\t}; qq{@$raRowPick\n}; }; }
I hope this is useful.
Cheers,
JohnGG
Update: just noticed a missing closing square bracket on the push line, now corrected.
Update 2: I also realise that i didn't explicitly answer you with regard to getting at an ID for a particular row. We could expand the printing loop with something along these lines.
foreach my $raRowPick ( @$raResults ) { print do{ local $" = qq{\t}; qq{@$raRowPick\n}; }; if( $raRowPick->[ 0 ] eq $theIdWeWant ) { doSomethingWith( $raRowPick[ 0 ] ); } }
|
|---|