in reply to How do I parse data received from a textarea

Presumably you're receiving the data as "foo=HHH9114\nEEE8888\nLLL4258\nPPP8525". You can replace these newlines with double pipes with this code fragment.
# Put value part in default variable. $_="HHH914\nEEE888\nLLL4258\nPPP8525"; # Search for newlines and replace with double pipes. s/\n/||/g; print "||$_||\n";
Prints out this:
||HHH914||EEE888||LLL4258||PPP8525||

metadoktor

"The doktor is in."

Replies are listed 'Best First'.
Re: Re: How do I parse data received from a textarea
by impossiblerobot (Deacon) on Jan 17, 2002 at 22:54 UTC
    Please note that what is sent for these "newlines" is dependent on what platform the browser is running on:
    \r\n for Windows \n for Unix \r for Macintosh

    Impossible Robot
Re(2): How do I parse data received from a textarea
by dmmiller2k (Chaplain) on Jan 18, 2002 at 09:37 UTC

    I'm not sure line separators differ with TEXTAREA fields no matter what OS is running on the machine with the Browser.

    In my own (less than vast) experience, I have had no problem using code like the following (AFAIK, has worked with Mac-, UNIX- and Windows-based browsers):

    # assuming text is in $_ my @lines = split /\n/; my $text = join '||', @lines; print "||$lines||\n";

    Or, in one line,

    print '||'. join('||', split( /\n/ )) .'||' ."\n";

    dmm

    If you GIVE a man a fish you feed him for a day
    But,
    TEACH him to fish and you feed him for a lifetime