in reply to Proper way to split a line with the "," delimiter

If I recall correctly, the split function should only remove missing values from the end of your input string:

$ perl -e 'print scalar(split /,/,"1,2,3,4")' 4 $ perl -e 'print scalar(split /,/,",2,3,4")' 4 $ perl -e 'print scalar(split /,/,"1,,3,4")' 4 $ perl -e 'print scalar(split /,/,"1,2,,4")' 4 $ perl -e 'print scalar(split /,/,"1,2,3,")' 3 $ perl -e 'print scalar(split /,/,"1,2,,")' 2

You'd best check perldoc -f split to see what it does in detail.

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^2: Proper way to split a line with the "," delimiter
by Anonymous Monk on Aug 17, 2018 at 16:19 UTC
    Hi all, thank you for your answers. I am maybe doing something else wrong then, I will double-check!