T
Ted Byers
I am setting up a new table for use in a PDF
The existing tables work fine, but their structure is static. I can
therefore use something like:
@row = ["Transaction type","Response text","Transaction Count"];
push @table2,@row;
@row = [$tt,$rt,$tc];
push @table2,@row;
When I pass @table2 to the PDF routine for maing tables, this works
flawlessly.
Now, however, I need to make a new table where the column names and
numbers are not know until run time. I tried the following, but all
that got displayed in the table were reference values:
$tmp= "Merchant";
push @row,$tmp;
foreach $action_type (sort @master_transaction_types) {
$tmp= "Percent $action_type transactions declined";
push @row,$tmp;
}
print "@row\n";
push @table4,\@row;
foreach $merchant (sort keys %declined_transaction_ratio) {
undef @row;
push @row,$merchant;
foreach $action_type (sort @master_transaction_types) {
push @row,$declined_transaction_ratio{$merchant}{$action_type};
}
print "@row\n";
push @table4,\@row;
}
NB: When I tried the above using "push @table4,@row;" instead of "push
@table4,\@row;", I got an error message complaining that "Merchant"
isn't a reference.
So, then, how do I create a table, like @table2 above, when the column
numbers and names are not known until run time?
I must have missed something simple, but what?
Thanks
Ted
The existing tables work fine, but their structure is static. I can
therefore use something like:
@row = ["Transaction type","Response text","Transaction Count"];
push @table2,@row;
@row = [$tt,$rt,$tc];
push @table2,@row;
When I pass @table2 to the PDF routine for maing tables, this works
flawlessly.
Now, however, I need to make a new table where the column names and
numbers are not know until run time. I tried the following, but all
that got displayed in the table were reference values:
$tmp= "Merchant";
push @row,$tmp;
foreach $action_type (sort @master_transaction_types) {
$tmp= "Percent $action_type transactions declined";
push @row,$tmp;
}
print "@row\n";
push @table4,\@row;
foreach $merchant (sort keys %declined_transaction_ratio) {
undef @row;
push @row,$merchant;
foreach $action_type (sort @master_transaction_types) {
push @row,$declined_transaction_ratio{$merchant}{$action_type};
}
print "@row\n";
push @table4,\@row;
}
NB: When I tried the above using "push @table4,@row;" instead of "push
@table4,\@row;", I got an error message complaining that "Merchant"
isn't a reference.
So, then, how do I create a table, like @table2 above, when the column
numbers and names are not known until run time?
I must have missed something simple, but what?
Thanks
Ted