Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: split tosses away empty components even with positive width separators?

by Laurent_R (Monsignor)
on May 06, 2013 at 11:05 UTC ( #1032244=note: print w/ replies, xml ) Need Help??


in reply to split tosses away empty components even with positive width separators?

It is not a bug, it is a feature. ;-)

A list of two empty lists is an empty list, there is nothing tremendously paradoxical about it, it is quite natural and common sense (even though a different design decision could possibly have been made, but it would probably have led to useless complexities).


Comment on Re: split tosses away empty components even with positive width separators?
Replies are listed 'Best First'.
Re^2: split tosses away empty components even with positive width separators?
by wrog (Friar) on May 06, 2013 at 12:32 UTC
    Perhaps so, if we were talking about a list of two empty lists, but a list of two empty strings is a totally different animal...

      Well, one must say that the behavior shown in the following debugger session does not seem to be completely consistent.

      DB<1> x split /-/, "-" empty array DB<2> x split /-/, "-foo-bar-" 0 '' 1 'foo' 2 'bar'

        But see the documentation pointed out by RichardK:

        >perl -wMstrict -le "printf qq{'$_' } for split /-/, '-foo-bar-', -1; " '' 'foo' 'bar' ''

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1032244]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2015-08-01 03:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (285 votes), past polls