in reply to regex or split

The split pattern can be made zero-width, and thus not removing the newline from the result:   @data = split /(?<=\n)/, $data; The advantage with this is that you don't have to make an exception, or premung the string, to handle the possibly missing trailing newline. (In your case you likely want to make sure there's no missing newline, but it's a useful technique to know anyway.) Using split() it's also very clear that you're performing a split and not an extraction. Another advantage is that you may set a limit, which can be an optimization if it's ever wanted.

An issue with the pattern is that the quantifiers have a max limit. Afaik it differes on different builds, but for very long lines this might be a problem. Perhaps not likely, but anyway. (perl -Mre=debug -wle '"a" =~ /a*/' will tell you your limit.)

Hope I've helped,
ihb

Update: Bah, pike got there first. :)