:  my @sections = split /\n(?=[a-z])/i, $dat;
: I have a doubt here.  perldoc -f split says,
: ------------------------------------------------------
:  If the PATTERN contains parentheses, additional array
:  elements are created from each matching substring in the
:  delimiter.
: 
:      split(/([,-])/, "1-10,20", 3);
: 
:  produces the list value
: 
:      (1, '-', 10, ',', 20)
: -----------------------------------------------------
: What will this zero width lookahead assertion create? AFAIK, (?=... ) does 
: not consume anything. 

It will split the string on a substring containing a newline followed a
letter, without consuming the letter.  Instead, the letter will remain
with the split substring. (The newline will be consumed, since it's not
included in the assertion.) So the assertion doesn't create anything;
it keeps the letter intact.

Note that the *final* newline in the file will *not* be consumed,
because it is not followed by a letter.

-- tdk

Reply via email to