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

Re: [perl #116086] split "\x20" doesn't work as documented

Thread Previous | Thread Next
From:
Dr.Ruud
Date:
February 17, 2013 12:14
Subject:
Re: [perl #116086] split "\x20" doesn't work as documented
Message ID:
20130217121401.20236.qmail@lists-nntp.develooper.com
On 2013-02-17 02:15, demerphq wrote:

> We changed which level of the perl parser handles escapes intended for
> the regex engine.
>
> Previous to this the \x20 would be resolved to a space, and as far as
> the regex engine was concerned the pattern would be " ".
>
> After this change the \x20 would be delivered to the regex engine
> verbatim and the \x20 form would not be recognized by the heuristic
> that handles the " " case.
>
> This change was very desirable for many reasons, and as it doesnt
> actually contradict the docs, unless Ricardo says otherwise I consider
> this Not A Bug.

See some split() cases below. So, #4 should behave as #7..10.

So, the PATTERN "\x20" should be compiled as /\x20/, not as " ".

-- 
Ruud


$ perl5.14.2 -MData::Dumper -wle '
   use constant SPC => "\x20";
   sub SPC0 () { "\x20" }
   sub SPC1 { "\x20" }
   my $SPC = "\x20";
   sub p { print shift, ":\t[", join( "][", @_ ), "]" }

   $_ = "\x20\x20\x20a b c\x20\x20";

   p  1, split undef;
   p  2, split;
   p  3, split " ";
   p  4, split "\x20";
   p  5, split SPC;
   p  6, split SPC0;
   p  7, split SPC1;
   p  8, split $SPC;
   p  9, split / /;
   p 10, split /\x20/;
   p 11, split "a";
   p 12, split /a/;
'
Use of uninitialized value in regexp compilation at -e line 9.
1:	[ ][ ][ ][a][ ][b][ ][c][ ][ ]
2:	[a][b][c]
3:	[a][b][c]
4:	[a][b][c]
5:	[a][b][c]
6:	[a][b][c]
7:	[][][][a][b][c]
8:	[][][][a][b][c]
9:	[][][][a][b][c]
10:	[][][][a][b][c]
11:	[   ][ b c  ]
12:	[   ][ b c  ]


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