in reply to Empty strings after split /(\W)/
Is there an explanation, why split() behaves like this:
Yes, because its documented that split behaves that way, split splits strings apart into pieces (split cuts), even if there is nothing in between
Read perldoc -f split and consider this
use Data::Dump qw/ dd /; dd( split /\D/, q/12Q34/ ); dd( split /\D/, q/12ab34/ ); dd( split /(\D)/, q/12ab34/ ); __END__ (12, 34) (12, "", 34) (12, "a", "", "b", 34)
split cuts a string apart, discarding the cut pieces unless you (keep) them
|
|---|