As you have provided incomplete code with no example data and no error messages, it is difficult to say where your problem is.
The documentation for PDF::Table indicates that your data should be in an array.
It can be used to display text data in a table layout within the PDF. The text data must be in a 2d array (such as returned by a DBI statement handle fetchall_arrayref() call).
Perhaps if you loop over your data to construct your array then pass that to generate the table in the pdf, it will do what you want.
Here is a rough example of how your code could be modified, as the code is incomplete this is untested.
my @tabledata;
foreach my $ship_prod (@SHIP_PRODS){
my($_t_id,$p_id,$stat_id,$qty) = split(/$SEP_CHAR/,$ship_prod);
$rows = ["", "$ALL_PRODS{$p_id}",""];
if(exists($ALL_MAN{$p_id}) && length($ALL_MAN{$p_id}) > 0){
$rows = ["", "$ALL_MAN{$p_id}",""];
}
push @tabledata, $rows;
}
# build the table layout
$pdftable->table(
# required params
$pdf,
$page,
\@tabledata,
x => 5,
start_y => 470,
next_y => 450,
start_h => 200,
next_h => 250,
# some optional params
w => 600,
padding => 5,
padding_right => 10,
font_size => 8,
)
A few brief pointers on your code:
- use strict and warnings, I am guessing you are not using these, based on the fact that you do not declare $rows with my in the snippet provided.
- Indent Indent Indent, whatever scheme for indenting you wish to use is fine as long as it is consistent, this will make your code far easier for you and everyone else to read
- Variable names, everyone has their own opinion on good variable names however I don't think many people would like $_t_id. Abbreviations can save some time typing but if it hinders readability and understanding you have to ask is it worth it. In your example code $p_id I can guess to be product_id but $stat_id and $_t_id are not obvious, nor is ALL_MAN
A tip for submitting questions to PerlMonks, break your problem down into a small but complete example that can be executed to see the exact error.