What is your expected output? Is it what you're showing in your second and third example?
Regarding grep {$_} ...: that will also filter out the string "0", since that's false in Perl. You may find grep {length} ... better.
However, personally, I like your third example best, because I feel like it expresses best what you want the output to be, but of course There's More Than One Way To Do It :-)
In reply to Re: Empty strings after split /(\W)/
by Anonymous Monk
in thread Empty strings after split /(\W)/
by wollmers
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |