develooper Front page | perl.perl5.porters | Postings from February 2012

Re: [perl #109798] '/e' regexp modifier is not recognized by re pragma

Thread Previous | Thread Next
From:
demerphq
Date:
February 6, 2012 02:43
Subject:
Re: [perl #109798] '/e' regexp modifier is not recognized by re pragma
Message ID:
CANgJU+Vm8DtpQk=L1T+R89XSMLCqUQsBuSyUrzAwHJYiQsHukQ@mail.gmail.com
On 5 February 2012 23:12, Eric Brine <ikegami@adaelis.com> wrote:
> On Sun, Feb 5, 2012 at 12:22 PM, demerphq <demerphq@gmail.com> wrote:
>>
>> On 5 February 2012 01:19, Eric Brine via RT <perlbug-followup@perl.org>
>> wrote:
>> > On Sat Feb 04 16:15:49 2012, ikegami@adaelis.com wrote:
>> >> On Sat Feb 04 04:05:02 2012, glitchmr@myopera.com wrote:
>> >> > When '/e' modifier is used with 're' module, Perl complains about
>> >> > unknown modifier. Personally, I think that informing about '/e'
>> >> > not being able to be used by 're' module would be more useful.
>> >> >
>> >> >     C:\Users\Konrad>perl -e "use re '/e'"
>> >> >     Unknown regular expression flag "e" at -e line 1
>> >>
>> >> That message is accurate.
>> >>
>> >> >perl -e" /(?e:x)/ "
>> >> Sequence (?e...) not recognized in regex; marked by <-- HERE in m/(?e
>> >> <-- HERE :x)/ at -e line 1.
>> >>
>> >> "e" is not a regular expression flag. It is a substitution operator
>> >> flag.
>> >
>> > Also note that "e" is not mentioned in perlre. The regex flags are (as
>> > listed in perlre): m, s, i, x, p, g, c, a, d, l, u.
>>
>> Just to note, perlre does not decide this. regexp.h does.
>>
>> > (I find this very odd that p, g and c are regex flags instead of match
>> > substitute operator flags, but they are are.)
>>
>> Huh?!
>>
>> /p relates to how we manage $`, $&, $', and has nothing to do with
>> substitution.
>>
>> /g relates to how match
>>
>> /c relates to how we match.
>>
>> None of them have anything to do with substitution.
>
>
> Perl disagrees.

No it does not.

I said "relates to how we match", which means "the m// modifier". Not
the qr// modifier. A qr// operator does not *match* anything. It
*compiles* a pattern, but does not use it to match. You have to use
m//, or a qr object on the rhs of a =~ to do a match.

>>perl -e"qr/foo/c"
> Having no space between pattern and following word is deprecated at -e line
> 1.
> Bareword found where operator expected at -e line 1, near "qr/foo/c"
> syntax error at -e line 1, near "qr/foo/c
> "
> Execution of -e aborted due to compilation errors.
>
>>perl -e"qr/foo/g"
> Having no space between pattern and following word is deprecated at -e line
> 1.
> Bareword found where operator expected at -e line 1, near "qr/foo/g"
> syntax error at -e line 1, near "qr/foo/g
> "
> Execution of -e aborted due to compilation errors.

$ perl -e'm/foo/g'
$ perl -e'm/foo/c'
$ perl -e'm/foo/p'

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