in reply to DBI::CSV using a variable to request columns
If I understand you, you want arbitrary columns from a database query. I think I would approach this by using an array of column names rather than a scalar containing (more or less) the code to be executed. That is, instead of your $columns, do something like my @columns = qw{ sid gender };, and then accumulate your $queryResult using something like
$queryResult .= join( "\t", map { "$_ = $row->{$_}" } @columns ) . "\n";
Note that I have not worried about validation of column names, but if you are getting them from user input you will need to.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: DBI::CSV using a variable to request columns
by Sandy_Bio_Perl (Beadle) on May 20, 2016 at 16:56 UTC |