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:
Tom Christiansen
Date:
February 17, 2013 01:57
Subject:
Re: [perl #116086] split "\x20" doesn't work as documented
Message ID:
770.1361066217@chthon
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.

--tom

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