$ instead of \z in regex

merlyn on 2007-04-16T10:59:51

Once again, I corrected a posting where someone had used $ instead of \z to anchor a regex "at the end" in a way that would have opened up a potential security hole. (The string would have matched ".foo\n" as well as ".foo", which could have led to some interesting mismatches later.)

I realize that this is a feature, but it's a subtle misfeature. I wish more people were educated about this situation.


Teach a man to fish...

sigzero on 2007-04-16T14:20:02

Where can I go to get educated about that?

Re:Teach a man to fish...

mw487 on 2007-04-16T19:15:48

Anything free comes with no guarantee.

http://www.regular-expressions.info/anchors.html

Help me add it to perl101.org

petdance on 2007-04-16T14:47:31

Please write up a short paragraph explaining it, and I'll add it to the regexes page at perl101.org.

Re:Help me add it to perl101.org

sigzero on 2007-04-16T15:19:39

I didn't know about that either!

Re:Help me add it to perl101.org

petdance on 2007-04-16T16:39:18

We haven't announced perl101.org yet. It's still (clearly) very alpha.

Re:Help me add it to perl101.org

sigzero on 2007-04-16T18:09:00

Yes, but now I have it bookmarked and can watch it grow. : )

PBP / perlcritic

draegtun on 2007-04-23T14:25:53

PerlCritic catches this.

In "Perl Best Practises".... Damian suggests always using /m flag.