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...)
Maybe some would disagree but to me I like to say my regexes out loud to understand them and I findif ( $scalar =~ /[^12345]/ ) { print "Illegal parameter: $scalar"; } else { print "Acceptable parameter: $scalar"; }
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.
In Section
Seekers of Perl Wisdom