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

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

  • Comment on Re: Re: Re: Re: Simple Question for you guys.

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Simple Question for you guys.
by chipmunk (Parson) on May 18, 2001 at 18:20 UTC
    It is an intentional feature of Perl that a backslash followed by a non-word character always means the literal character, whether in a regex or a double-quoted string. Other languages and tools may use \( and \) for capturing parentheses, or \< and \> for word boundaries.

    Perl's rule is very simple. Personally, I don't see any harm in taking advantage of it. In fact, I think it is less likely to cause confusion, because another programmer can just look at the code and know immediately that \< means a literal <, without having to look at the docs or trying it out.

Re: Re: Re: Re: Re: Simple Question for you guys.
by blue_cowdawg (Monsignor) on May 18, 2001 at 17:52 UTC
      Escaping unnecessarily is a good way to confuse the next programmer to maintain your code.

    As somebody who has done a lot of code maintenance on other folks code I would have to say that I never been confused by an escaped character.

    There are plenty of other sins out there that can cause confusion when maintaining code, believe me. If "unnecessary" escaping was the worst thing I ever saw I'd still have a full head of hair!

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

      OK. So maybe I should have said "Escaping unnecessarily is a good way to potentially confuse the next programmer to maintain your code".

      I still think there's no good reason to add extra escapes. It shows laziness[1] on the part of the programmer and would'nt get thru any code review that I was conducting.

      [1] And it's the bad kind of laziness :)

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

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