in reply to My Novice is Showing

What you're doing seems very odd. Perhaps you should have a slightly more complex data structure to associate those magic numbers with the variables they correspond with.

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.

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"', @$_); } }
Alternatively,
my $tkt_data = join ',' => map(sprintf('"%s%", "%s"', @$_) => grep($_->[1] ne '', @ar));