On 2006-01-18 10:04 AM, "David K Storrs" <[EMAIL PROTECTED]> wrote: > Just to show opposite, I've always found that behavior (i.e. > returning the original string unchanged) confusing. C<split> works > based on sequential examination of the target string to locate > matching substrings on which to split. There is a matching "empty > string" substring between every character. Naturally, what you get > back is an array of characters. > > Plus, it's a useful idiom.
You misunderstand. We're not talking about splitting a string with the empty string as the delimiter. We're talking about splitting the empty string (as the target), with any delimiter whatsoever. If you do that, what you get back is an empty array. Perl6 "".split(/whatever/) is equivalent to split(/whatever/,"") in Perl5. It's not like the silly Python idiom where the invocant is the delimiter string. :) So this is the Perl5 to which I was referring: my @result = split(/whatever/, ""); print [EMAIL PROTECTED],"\n"; # --> 0 The general case I was comparing it to is when the target string is *not* empty but doesn't match, in which case you get the original string back: my @result = split(/foo/, "bar"); print [EMAIL PROTECTED],"\n"; # --> 1 print $result[0],"\n"; # --> "bar"