in reply to converting carriage returns to <br> tags (was: Simple Question for you guys)

my $text=$cgi->param('mytextfield'); $text =~ s/\n/\<br\>/g; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Peter L. Berghold --- Peter@Berghold.Net "Those who fail to learn from history are condemned to repeat it."

Replies are listed 'Best First'.
Re: Re: Simple Question for you guys.
by AidanLee (Chaplain) on May 18, 2001 at 17:30 UTC
    why have you escaped the < and > symbols? AFAIK they are not special inside a regex.

      Simple. I felt like it. When in doubt escape. It doesn't cost much and it certainly doesn't hurt.

      ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      Peter L. Berghold --- Peter@Berghold.Net
      "Those who fail to learn from history are condemned to repeat it."
      

        But there's no reason to be in doubt. Simply read the documentation - or try it out - and you'll know whether or not you need to escape characters.

        Escaping unnecessarily is a good way to confuse the next programmer to maintain your code.

        --
        <http://www.dave.org.uk>

        "Perl makes the fun jobs fun
        and the boring jobs bearable" - me