in reply to Is this concise enough? (code)
The first splits on "\n ", producing ('abc', 'def'), while the second splits on "\n" and " ", producing ('abc', '', 'def'). In other words, split /\n|\s+/ will give you null strings where there's a newline followed by whitespace (including blank lines).my @fields = split ' ', "abc\n def"; my @fields = split /\n|\s+/, "abc\n def";
One other point; your code depends on having exactly six slots. You might consider writing it to work with any number of slots.
|
|---|