On Fri, Jan 11, 2008 at 12:14:03PM +0000, Victor Churchill wrote:
> On 11/01/2008, Colin Wetherbee <[EMAIL PROTECTED]> wrote:
>
> > (As an aside, how do you guys quote your queries? I find that for
> > anything longer than about 60 characters, q() and '' and everything else
> > start to look horribly inelegant.)
>
> Can't comment on your main question, but on the secondary query-layout
> topic, I find this works quite nicely:
> $query2 = qq/SELECT MTR_REFERENCE FROM ALLOCATED_METERS,METERS /;
> $query2 .= qq/WHERE ALM_MTR_ID = MTR_ID /;
> $query2 .= qq/AND ALM_LP_ID = ( /;
> $query2 .= qq/ SELECT LP_ID /;
> $query2 .= qq/ FROM LOGGER_POINTS,ALLOCATED_METERS,METERS /;
> $query2 .= qq/ WHERE LP_ID=ALM_LP_ID /;
> $query2 .= qq/ AND MTR_ID=ALM_MTR_ID /;
> $query2 .= qq/ AND MTR_REFERENCE = ? ) /;
>
> (In a mono font the right hand /;'s align, for neatness, but that's optional).
>
> Nice thing doing it this way is that it does not confuse the editor's
> auto indent.
On the other hand, you can't easily copy-n-paste the query into other
tools, which I'd find much more frustrating. I'd also find the extra
line noise distracting. And when the query needs changing I'd find the
extra effort to maintain that layout would be a pain, literally.
I almost always use q{} or qq{} for multi-line strings.
(Using a bracketing character like {, (, [ etc. means that perl will
also take care of skipping any nested brackets within the string without
them beeding to be escaped.)
Tim.