ibra has asked for the wisdom of the Perl Monks concerning the following question:
my $eachQuery = "SELECT * FROM example ORDER BY num; "; my $sth2 = $epm_db->Query($eachQuery); $sth2->execute(); # get example table headings my @eachCols = @{$sth2->{NAME}}; # or NAME_lc if needed my $EachVals = ""; while ( my $dat_ref2 = $sth2->fetchrow_hashref("NAME_lc") ) { foreach my $val(@eachCols) { #print $dat_ref2->{$_}; if ($EachVals eq "") { $EachVals = $dat_ref2->{$val}; } else{ $EachVals = $EachVals."\t".$dat_ref2->{$val}; } } print MYEach "$client\t$EachVals\r"; # printing values into csv output + file }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: looping hash
by TJPride (Pilgrim) on Mar 02, 2012 at 18:08 UTC | |
by ibra (Novice) on Mar 07, 2012 at 16:33 UTC |