Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Re: Detect presence of numbers 1-9

by demerphq (Chancellor)
on Apr 08, 2002 at 10:17 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2024-04-18 16:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found