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

Re: Changes in m//m in 5.10

Thread Previous | Thread Next
From:
demerphq
Date:
December 21, 2007 04:09
Subject:
Re: Changes in m//m in 5.10
Message ID:
9b18b3110712210408q501908ej348d8e1ece32a287@mail.gmail.com
On 21/12/2007, Rafael Garcia-Suarez <rgarciasuarez@gmail.com> wrote:
> On 21/12/2007, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
> > On Dec 20, 2007 9:39 PM, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
> > > On 12/19/07, demerphq <demerphq@gmail.com> wrote:
> > > > Probably it would be better to simply warn "Useless use of modifiers
> > > > on m/// at line ...".
> > >
> > > Here's an incomplete patch that implements this, could someone with
> > > better luser communication skills fix the diagnostics message please?
> >
> > Here's a complete one, thanks dmq!
>
> I haven't tested, but isn't this going to warn even in cases like the
> following?:
> my $r = qr/^foo/;
> /$r|^bar/m;

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)

cheers,
Yves


-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

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