Split automatically saves anything in parentheses into the output list. This is so that a split like this:
split /([,-])/, "1,10-20"
Will produce output like this:
"1", ",", "10", "-", "20"
I believe this is a mis-feature, but we get to live with it. Since split only saves values that get stored into $1 and kin, you can stop this behavior by not saving anything in those special variables. Either omit the paranthesis if unnecessary, or use the (?: ... ) format, which doesn't save any values into $1.

-Ted

Replies are listed 'Best First'.
Re: Answer: How can I split without getting null fields from Whitespace?
by chipmunk (Parson) on Dec 09, 2000 at 02:48 UTC
    How could that be a misfeature? You said yourself, if you don't want the delimiters to be saved, don't use capturing parentheses. Very simple.