Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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.




  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-26 07:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found