in reply to My Novice is Showing

a comma should be appended at the end of each pair only if another pair is to be appended.
Sounds like a job for join. Build an array/list of all your "12345", "$p_xxxx" strings and join them with ", ".

As for the other restrictions, notice that you've had to hardcode every variable separately because they all have different ID numbers. If you were to group all the related $p_xxxx variables into one hash, and build a hash that maps record fields to ID numbers, your life could be a lot simpler:

my %id_map; my @fields = qw/suby stat desc catg agrp lnam/; @id_map{@fields} = qw/2 7 8 536870915 536870922 536870926/; ######### my %p_record = ( suby => "foo", stat => "bar", desc => "baz", catg => "", agrp => "boo", lnam => "" ); my $tkt_data = join ", " => map { qq["$id_map{$_}", "$p_record{$_}"] } grep { length $p_record{$_} } @fields; print "$tkt_data\n"; # "2", "foo", "7", "bar", "8", "baz", "536870922" +, "boo"
Now there are no individual cases, no plethora of if-statements, because all fields can now be handled the same way. Their ID number is fetched from the %id_map hash.

blokhead