Random tip. I prefer to use the qq{} syntax so that the interpolated string doesn't stick out from my code. I also have a slightly different standard for writing SQL. So a basic example could look like this:
my $sth = $dbh->prepare(qq{
select
tbl.column1
, tbl2.column2
from tbl1
join tbl2
on tbl1.tbl2_id = tbl2.id
where condition = ?
and condition2 = ?
}) or die "Can't prepare query: $DBI::errstr";
The basic idea being that continuation pieces like "," and "and" go in front of the next line rather than trailing on the previous line. The point being that when you go to change your SQL you're likely to add columns and/or conditions, and with my way of arranging things you avoid the annoying error where you insert a bunch of rows but forgot to add the continuation piece just before your insert.
You don't have to do things that way, but if you write as much SQL as I do, you'll find that it makes sense.
Update: zwon pointed out that I missed the qq{} in the code even though I had just talked about it. D'oh, fixed.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.