I didn't say that a here doc is a _bad_ solution, just too much of a solution. Because i use placeholders ( see bind values), i don't need inner quotes, but there is nothing stopping you from using placeholders inside a here document, either. It really is just a matter of style.

A good use for here docs is for user display, and i don't mean debugging. But since i discovered the wonderful world of templating, i haven't used a here doc in a long, long time.

I rather like this quick and dirty method of encapsulating a SQL query, i really think that here docs add line noise:

sub get_artists { my $artist = shift() . '%'; return $dbh->selectcol_arrayref(' select name from artist where name like ? ',undef,$artist); }
All i need is a pair of single quotes. But, this week taught me a pretty important lesson - there really are CPAN modules that take away having to even worry about such issues ... check out the replies by princepawn and autarch at Save MP3 Tag's to Database with SPOPS. (please note that SPOPS itself is meant for much more than what i presented.)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
F--F--F--F--F--F--F--F--
(the triplet paradiddle)

In reply to (jeffa) 4Re: SQL Query by jeffa
in thread SQL Query by Anonymous Monk

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.