Because this is Perl, There Is More Than One Way To Do It (whatever "It" happens to be.)

Another way to build the query string is:

my $dbCommand = do {
    local $" = ',';
    "select @ticketsFields ...";
};

The $" variable determines what gets put between elements when you interpolate an array. If you use English; you can spell this $LIST_SEPARATOR. No matter which spelling you use you should localize the value to avoid spooky action at a distance, since this variable is global. The do block limits the scope of the local change to $". I do not present this as a better way to build the query string, simply as another way.

Nitpick (or maybe not): Unless variables like @ticketsFields actually need to be visible outside your module, you could (and probably should) specify them as my rather than our. This may actually have practical consequences in the case of @ticketsRecords. Since you declared it our, there is only one instance of it. So if you do something like

my $rec_1 = getTicketsRecords( ... );
my $rec_2 = getTicketsRecords( ... );

$rec_1 and $rec_2 refer to the same array, and contain the same data -- the results of the most recent call to getTicketRecords(). If you say my @ticketsRecords, each call returns a reference to a different array.


In reply to Re: Is there a cleaner way to write this code below, which includes derferencing references, that themselves have to be dereferenced? by Anonymous Monk
in thread Is there a cleaner way to write this code below, which includes derferencing references, that themselves have to be dereferenced? by bartender1382

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.