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

In reply to Re: My Novice is Showing by Roy Johnson
in thread My Novice is Showing by Red_Dragon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.