in reply to My Novice is Showing
One major thing you're doing wrong is using numeric comparisons (!=) when you should be doing string comparisons (ne). You are also overwriting $tkt_data instead of appending to it.
This is untested, but might do what you want. Season to taste.
Alternatively,my @ar = ( ['2', $p_suby], ['7', $p_stat], ['8', $p_desc], ['536870915', $p_catg], ['536870922', $p_agrp], ['536870926', $p_lnam] ); my $tkt_data = ''; for (@ar) { if ($_->[1] ne '') { $tkt_data .= ',' if $tkt_data ne ''; $tkt_data .= sprintf('"%s%", "%s"', @$_); } }
my $tkt_data = join ',' => map(sprintf('"%s%", "%s"', @$_) => grep($_->[1] ne '', @ar));
|
|---|