Awesome!
That worked, although the lines were actually terminated by \r\n - my
superb observational skills at work again. Although I chomped each line,
that would have only removed the trailing \r (depending on the value of
$/, that is), and not the \n on the next line.

That had me stumped for about four days. Thanks!

On Tue, 5 Jun 2001, Timothy Kimball wrote:
>
> Len Walter wrote:
> : Since the data is "string\n\rstring" I figured I could use split /^/ to
> : separate out the individual strings. There's probably an easier way to do it
> : though... the split seems to work correctly, and both @strings and %content
> : get filled apparently ok.
>
> Try splitting on /\n\r/ instead. /^/ actually matches the beginning of
> a string *or*, with split or in matching with /m, right after a newline
> (\n), without consuming any characters (it's an assertion). So if $data
> is
>
>       "Line one\n\rLine two"
>
> then "split /^/, $data" gives
>
>       Line one\n
>       \rLine two
>
> In other words, the \n\r is split and left attached to the pieces.
>
> Splitting on /\n\r/ avoids this.
>
> -- tdk
>

Reply via email to