in reply to catching \n

You are probably looking for /g, substitute globally. Your example will only get the first \r and \n in $blah. Just use something like this which will also handle DOS style returns

$blah =~ s/\r?\n/<br>/g;

Replies are listed 'Best First'.
Re2: catching \n
by bbfu (Curate) on Aug 07, 2003 at 01:38 UTC

    Or, if you want to be really portable, you could use s/\r?\n|\n?\r//g. That should catch most every platform's newline style, IIRC.

    bbfu
    Black flowers blossom
    Fearless on my breath

      If the web client (browser) doesn't use ASCII "\r\n"1 for newline in the text it sends to you, then the web client is broken, IMHO.

      1Note that this is not ambiguous. I know that "\r\n" on old Macs results in ASCII "\n\r", but that is because those Macs are near-ASCII systems despite them claiming to be ASCII systems. q-:

                      - tye