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

Re: Changes in m//m in 5.10

Thread Previous | Thread Next
From:
Joshua ben Jore
Date:
December 22, 2007 15:08
Subject:
Re: Changes in m//m in 5.10
Message ID:
dc5c751d0712221507l3b7c59f0vdacef7dcdd122c6a@mail.gmail.com
On Dec 22, 2007 6:35 AM, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
> On Dec 21, 2007 12:08 PM, demerphq <demerphq@gmail.com> wrote:
> > No it wont actually. The warning would only be raised when the $qr
> > variable is the only thing in the pattern. The diagnostics should read
> > (added an 'only'):
> >
> > +(W regexp) Your pattern contains only a variable containing a precompiled
> > +regular expression pattern whose behavior will not be changed by the
> > +pattern modifiers provided.
> >
> > $qr=/^foo/;
> > $x=~/$qr/m; # warns;
> > $x=~/$qr|foo/m; #does not warn
> > $x=~/$qr/x;  # does not warn (/x doesnt change match semantics)
>
> In the current implementation yes, but we might potentially want to
> warn in the future on useless modifiers in general, eg:
>
> $x =~ /(?-msix:^foo)/msi;

That would be hilarious as it'd presumably throw warnings at people
who uselessly used the /msx modifiers as suggested by Damian's PBP.
Mostly I find uselessly adding /msx makes it harder to read code
because I have to guess more about intent and it's noise. I'd be all
for this sort of warning.

Josh

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About