Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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

by wrog (Friar)
on May 06, 2013 at 12:32 UTC ( [id://1032269]=note: print w/replies, xml ) Need Help??


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

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...
  • Comment on Re^2: split tosses away empty components even with positive width separators?

Replies are listed 'Best First'.
Re^3: split tosses away empty components even with positive width separators?
by Laurent_R (Canon) on May 06, 2013 at 15:09 UTC

    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' ''

        Yeah, I had seen that point made by RichardK, but I was really referring to what is happening at the beginning of the string, which is not completely consistent. In one case you get an empty string, and in the other case you don't get it.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-23 06:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found