develooper Front page | perl.perl5.porters | Postings from May 2016

[perl #128302] split docs don't mention pattern modifiers

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
May 31, 2016 21:17
Subject:
[perl #128302] split docs don't mention pattern modifiers
Message ID:
rt-4.0.18-24556-1464729408-1990.128302-15-0@perl.org
On Tue May 31 14:14:16 2016, sprout wrote:
> On Tue May 31 13:59:22 2016, smylers@stripey.com wrote:
> > Abigail writes:
> >
> > > On Tue, May 31, 2016 at 09:06:57AM -0700, Smylers wrote:
> > >
> > > > Are all the qr/PATTERN/ flags also valid on split?
> > >
> > > I think they are, but some warn. For instance:
> > >
> > > $ perl -wE 'our @a = split /f/g, "foo"'
> > > Use of /g modifier is meaningless in split at -e line 1.
> >
> > /g is an m// modifier. perlop documents that m// takes all of the
> > qr//
> > modifiers plus /g and /c.
> >
> > > But I haven't checked all of them.
> >
> > I was hoping that somebody might already know, but if not I'll go
> > through them.
> 
> It does accept all the modifiers that m// accepts, because there is
> actually an m// op there at compile time initially, before ck_split
> makes its exotic changes to the op tree.  After all, you can write
> split m//....

If you do change the docs, please don’t make it imply that split "foo" can take modifiers.  split per se does not actually take any, but rather the m// that serves as its first argument.  (In fact, the idea of split taking modifiers is not a way I have ever looked at it, even before I knew perl internals.)

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=128302

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