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, )