in reply to regex or split

If I understand your question right, you don't want the \n chopped off the end of each line. The answer is: use positive look-behind assertions (see perlre). These have zero width, therefore what they match is not lost in the split:

@data = split /(?<=\n)/, $data;
HTH,

pike

Replies are listed 'Best First'.
Re: Re: regex or split
by mce (Curate) on Feb 06, 2003 at 13:51 UTC
    And the winner is....

    I knew that is should be easier that split+map.


    ---------------------------
    Dr. Mark Ceulemans
    Senior Consultant
    IT Masters, Belgium