Skip to content

use re '/aansx'; breaks split " ", ... #18032

Open
@druud

Description

@druud

$ perldoc -f split
[...] As another special case, "split" emulates the default behavior of the command line tool awk when the PATTERN is either omitted or a string composed of a single space character
[...] In this case, any leading whitespace in EXPR is removed before splitting occurs, and the PATTERN is instead treated as if it were "/\s+/";
[...] in Perl 5.18.0 and later this special case is triggered by any expression which evaluates to the simple string " ".
[...] If omitted, PATTERN defaults to a single space, " ", triggering the previously described awk emulation.
[...]

$ perl -Mstrict -wE'

  my $s= "  foo  bar  ";

  say for split " ", $s;

  { use re qw( /aansx );
    say for split " ", $s;
  }
'
foo
bar
 
 
f
o
o
 
 
b
a
r 



---
Site configuration information for perl 5.24.3:

Configured by root at Tue Feb 13 14:35:15 CET 2018.
[...]
Locally applied patches:
    fix for #132063
    fix for #132227
[...]

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions