in reply to assigning to array from a split with some empty fields

from perldoc -f split:

Empty leading (or trailing) fields are produced when there are positive width matches at the beginning (or end) of the string; a zero-width match at the begin- ning (or end) of the string does not produce an empty field.

Update:Eeeek, disregard this ugly tip of mine; I should've read further in the mentioned perldoc....

A possible cure:

$text = 'a|b|c|||||||||e||||'; @array = split(/\|/,$text . '|MY_END_MARKER'); @array = @array[0..$#array-1]; use Data::Dumper; print Dumper(\@array); print scalar(@array), "\n";
Note: This produces 16 elements, as the last empty element isn't omitted; just change the -1 into -2 to handle this.

regards,
tomte


An intellectual is someone whose mind watches itself.
-- Albert Camus