John Williams wrote:

On Thu, 5 Dec 2002, Joseph F. Ryan wrote:

Peter Haworth wrote:

On Thu, 5 Dec 2002 04:05:05 -0500, Tanton Gibbs wrote:

A string inside a \qq[] construct acts exactly as if it were an
interpolated string. Note that any end-brackets, "]", must be escaped
within the the \qq[] construct so that the parser can read it correctly.


Note that an end-bracket, ], must be escaped within the \qq[] construct.
This allows the parser to correctly parse the construct.

Don't embedded qq[] strings obey the normal qq[] rules? That is, will
all brackets need escaping, or just unbalanced brackets? I'd hope for
the latter.

With all of the new crazy quoting shenanagains, I'm not sure that the
"balenced brackets are fine" rule will still be possible; and thus end
delimeters will always need to be escaped. For instance, imagine
what a nightmare this would be to parse:

$var = qq[blah [\q[blah [\qq[%hash{qq[[hi]]}]]]] blah];

Sure, anyone who writes something like this deserves to be shot;
however, if the "balanced brackets are ok" rule still stands, the
above code would be legal. (And I really, really, really don't
want the above code to be legal ;)

Well, just don't do it then.  With or without balanced brackets, the
obfuscating programmer can do the above; he just needs more or less
backslashes.

Saying "Just don't do it" doesn't stop someone from doing it.  True,
the example was an obfuscated one, but it was to prove a point.  This is
just as obfuscated in my opinion:

$var = qq[[[%hash{qq[one]}{qq[next]}],[],[%hash{qq[hi]}{qq[there]}]]];

Adding backslashes to the first example helps clear up some of the
confusion:

$var = qq[blah [\q[blah [\qq[%hash{qq[[hi\]]}]\]]\]blah];

Maybe it should be required that opening and closing delimiters should
be backslashed (even if the string can be parsed without the opening
delimiter escaped) just for legibility?  Then the first example becomes
even clearer:

$var = qq[blah \[\q[blah \[\qq[%hash{qq[\[hi\]]}]\]]\]blah];

Really, I think that if you really feel the need to use a delimiter
that you know that will be in the text that you are quoting, you should
have to go through the trouble of escaping it.  Its only fair :)

'\qq[]' is the real source of evil here.

Actually the apocalypse says:


RFC 226: Selective Interpolation in Single Quotish Context.

This proposal has much going for it, but there are also difficulties,
and I've come close to rejecting it outright simply because the
single-quoting policy of Perl 5 has been successful.

Maybe if we pushed Larry a bit, he could reject it after all?

Why?  I love \qq[] and \q[].  I'd much rather have embedded strings
than be able to balance used delimiters inside quotes.  I don't like the
"balance delimeters" rule at all, and don't see it as anything more
than an ugly hack.  I'd much rather have it go than embedded strings.

Personally I like 'not interpolated'_"interpolated"_'not interpolated'
much better than  'not interpolated\qq[interpolated]not interpolated'.

What about:

q[
not-interpolated  not-interpolated  not-interpolated
not-interpolated  \qq[interpolated] not-interpolated
not-interpolated  not-interpolated  \qq[interpolated]
not-interpolated  not-interpolated  not-interpolated
not-interpolated  not-interpolated  not-interpolated
\qq[interpolated] not-interpolated  \qq[interpolated]
not-interpolated  \qq[interpolated interpolated]
];

compared to:

q[
not-interpolated  not-interpolated  not-interpolated
not-interpolated  ] ~ qq[interpolated] ~ q[ not-interpolated]
not-interpolated  not-interpolated  ] ~ qq[interpolated] ~ q[
not-interpolated  not-interpolated  not-interpolated
not-interpolated  not-interpolated  not-interpolated
] ~ qq[interpolated] ~ q[ not-interpolated  ] ~ qq[interpolated] ~ q[
not-interpolated  ] ~ qq[interpolated  interpolated
];

Reply via email to