develooper Front page | perl.perl5.porters | Postings from December 2011

Re: [perl #107262] Unmatched \Q \E in regexp should warn

Thread Previous | Thread Next
Eric Brine
December 29, 2011 09:35
Re: [perl #107262] Unmatched \Q \E in regexp should warn
Message ID:
On Thu, Dec 29, 2011 at 5:48 AM, Ed Avis <> wrote:

> # New Ticket Created by  "Ed Avis"
> # Please include the string:  [perl #107262]

> I expected a warning from these because \Q and \E are not matched:
> % perl -wE '$_ = "a"; /\Qa/ or die'
> % perl -wE '$_ = "a"; /a\E/ or die'
> I suggest that at the end of the regexp, if a \Q is still open then
> warn.

Unterminated \Q has been seen as perfectly acceptable, and is commonly
used. Warning on it would create too many spurious warnings. This check
belongs in linters (e.g. perlcritic).

If \E is found but there was no active \Q \l \u \L \U then warn.

\u and \l have nothing to do with \E, but warning on \E if there's no \Q,
\L or \U in effect sounds appropriate to me.

- Eric

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About