Hi Monks, I'm trying to create a robust script that executes a for loop and calls different sql based on the value in $_ , but the "prepare" statement doesn't like the fact that it's a variable of a variable. Basically, I'm creating an excel spreadsheet using the Spreadsheet::WriteExcel module and looping thru the multi-dimensional array to call each sql statement. Hopefully there is a way around this otherwise i'll have to hard code all of my prepare statements. And with Perl..there has to be a way.
my @reports = ( [doc_request => [qw(T_Doc_Request N_Doc_Request X_Doc_Request)]], [doc_errors => [qw(T_Doc_Errors N_Doc_Errors X_Doc_Errors )]], ); my $T_Doc_Request=qq{select.... }; my $N_Doc_Request=qq{select... }; my $X_Doc_Request=qq{select... }; my $T_Doc_Errors=qq{select.... }; my $N_Doc_Errors=qq{select... }; my $X_Doc_Errors=qq{select... }; for (@reports) { my $report = $_->[0]; $worksheet->write(1, 0, $report, $header); $i++; for my $section (@{$_->[1]}) { print qq{report '$report', section '$section'\n}; $cell_column = 0; $worksheet->write($i, $cell_column, $section,$format1); $cell_column++;
the following does not work because $section ends up being T_Doc_Request and i need it to be $T_Doc_Request
my $sth = $dbh->prepare($section); $sth->execute; while ( my @row = $sth->fetchrow_array() ) { print ">@row<\n"; $worksheet->write($i, $cell_column, @row[$cell_column],$forma +t1); }#end while $sth->finish; }#end for section }# end for report
Any help is greatly appreciated thanks
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |