http://www.perlmonks.org?node_id=287570


in reply to Tutorial suggestion: split and join

Regular expressions are used with the split function to break up strings into a list of substrings. The converse to split is the join function, which takes a list of strings and joins them together again.
No. The converse to a split is a regular expression (with matching). The idea here is that with matching you specify what you want to match and you get that as a return value ala @simpsons = "Bart Lisa Maggie Marge Homer" =~ /(\w+)/g). With split you specify all the things you don't want and you get everything else. Which one you use depends on what is more natural to specify. I'm glossing over the fact that plain regular expressions are actually even more powerful than that but that's how they compare with split anyway (which itself uses a regex as its first parameter).

If split is given a null string as a delimeter, it splits on each character in the string, and since the delimeter is nothing at all, nothing at all is thrown away.
No. The empty regular expression matches at every position possible which includes between characters. This is how anchoring works. As an example, ^ normally matches the position before the first character. This is only possible if the "spaces" before, after and between characters are also places to match. So when matching "ab" with // it can match before the "a", the "a", between the "a" and the "b" and after the "b". When you actually run that the only parts that get returned in the split is the "a" and the "b".

The word "delimit" isn't spelled with an 'e' in it.