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

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

Thread Previous | Thread Next
Tom Christiansen
February 17, 2013 01:57
Re: [perl #116086] split "\x20" doesn't work as documented
Message ID:
I've seen people try to do this:

    my $delim = $if_something ? " " : qr/\s+/; 
    @fields = split $delim, $string;

And they are *very* surprised that it doesn't work the same as

    @fields = split $if_something ? " " : /\s+/, $string;

That is really hard to explain, you know?  Not easy to justify either.

Either it should clearly state that this space trick is a magic literal
literal and that cannot be in variable, or else it should be fixed so
anything that shows up as a U+0020 counts as that.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About