split /PATTERN/,EXPR
I read the following in a book,
When you use a pattern in split, be sure to avoid memory parantheses
in the pattern since these trigger seperator retention mode.
I can’t seem to find the documentation which explains this in detail. Could someone please explain Seperator Retention Mode and its possible usage briefly?
This is documented in
perldoc -f splittowards the end (in-code commentary is my own):So, two interesting quirks that may catch out the unwary:
The generation of
undefs in list context whenever a capturing group does not match, but something else inPATTERNdoesYou might split with a capture group, specifying
LIMITas$n, and the resultant list has more than$nelements