Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Re: Detect presence of numbers 1-9

by demerphq (Chancellor)
on Apr 08, 2002 at 10:17 UTC ( #157405=note: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://157405]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (10)
As of 2021-06-16 15:05 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (76 votes). Check out past polls.