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)
| [reply] [d/l] |