in reply to Re^2: Regex : Return match elements
in thread Regex : Return match elements
Split uses a regex (regular expression) to decide when to create elements of the resulting array. The code uses & or | to decide when to "make a new array element". Normally, in most splits, it is desired to "throw away" the split characters. Classic is: split /\s+/, $line; to parse space separated tokens. The use of a capture group in the regex allows the "splitted upon tokens" to appear in the output. This is an unusual situation, but works here.