++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Peter L. Berghold --- Peter@Berghold.Net
"Those who fail to learn from history are condemned to repeat it."
| [reply] |
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
| [reply] |
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.
| [reply] |
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."
| [reply] |