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)

Q is not a digit between 12 and 34
empty string "" is not a digit between a and b
empty string "" is not a digit between a and b (a and b are preserved not discarded

split cuts a string apart, discarding the cut pieces unless you (keep) them