http://www.perlmonks.org?node_id=157405


in reply to Re: Detect presence of numbers 1-9
in thread Detect presence of numbers 1-9

if ( $scalar !~ /[^12345]/ ) { print "match"; }

Hmm, that double negative sure is confusing. Maybe simplifying it would be a little clearer (I know regexes pretty well and I had to think about this for a second...)

if ( $scalar =~ /[^12345]/ ) { print "Illegal parameter: $scalar"; } else { print "Acceptable parameter: $scalar"; }
Maybe some would disagree but to me I like to say my regexes out loud to understand them and I find

if it matches any character that isn't a 1-5 then it is bad

much easier (read faster) to understand than

if it does not match any character that is not a 1-5 then it is good.

I agree im probably being a bit pedantic but I think you can see what I mean...

Yves / DeMerphq
---
Writing a good benchmark isnt as easy as it might look.