split docs don't mention pattern modifiers #15379
This is a bug report for perl from Smylers@stripey.com,
perldoc -f split doesn't state that split /PATTERN/ can use pattern
./perl -Ilib -E 'say foreach split /a b # c/, q[0aB1a b # c2a B # c 3]'
./perl -Ilib -E 'say foreach split /a b # c/ix, q[0aB1a b # c2a B # c 3]'
This should be included in split's documention.
Are all the qr/PATTERN/ flags also valid on split? (With the already
Site configuration information for perl 5.25.2:
Configured by smylers at Tue May 31 13:40:14 BST 2016.
Summary of my perl5 (revision 5 version 25 subversion 2) configuration:
@INC for perl 5.25.2:
Environment for perl 5.25.2:
On Tue, May 31, 2016 at 09:06:57AM -0700, Smylers wrote:
I think they are, but some warn. For instance:
$ perl -wE 'our @a = split /f/g, "foo"'
But I haven't checked all of them.
/g is an m// modifier. perlop documents that m// takes all of the qr//
I was hoping that somebody might already know, but if not I'll go
On Tue May 31 13:59:22 2016, firstname.lastname@example.org wrote:
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//....
On Tue May 31 14:14:16 2016, sprout wrote:
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.)
Thank you for filing this report. You have helped make Perl better.
With the release today of Perl 5.26.0, this and 210 other issues have been
Perl 5.26.0 may be downloaded via:
If you find that the problem persists, feel free to reopen this ticket.