in reply to Empty strings after split /(\W)/
Think of it like a really simple CSV file*. Your separator character is \W. To make it easier to think about, replace all \W with a comma, and your input string is "Hello,,World,,,".
split /,/, "Hello,,World,,," gives you the list "Hello", "", "World" (trailing empty fields are stripped as documented).
What you're asking split to do when you say split /(,)/, "Hello,,World,,," is keep the separator character in the list of return values (also the empty fields between separators aren't stripped). Hence:
$ perl -e 'print join("|",split(/(\W)/,"Hello,,World,,,")),"\n";' Hello|,||,|World|,||,||,
* Just for the sake of discussion, we all know we should be using Text::CSV instead of split ;-)
|
|---|