Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: regular expressions with !

by Tomte (Priest)
on Sep 14, 2006 at 14:34 UTC ( #572932=note: print w/ replies, xml ) Need Help??


in reply to regular expressions with !

You're a victim of operator precedence - the ! has higher precedence than =~ - so your expression evaluates as if ((!$test_string)=~/$regex/), which is false.

Either use !~, as already suggested, or use parenthesis around the whole match if (!($test_string =~/$regex/)).

You do not need to use the /e modifier!

regards,
tomte


An intellectual is someone whose mind watches itself.
-- Albert Camus


Comment on Re: regular expressions with !
Select or Download Code
Re^2: regular expressions with !
by svenXY (Deacon) on Sep 14, 2006 at 15:07 UTC
    Hi,
    thanks Tomte++! The only explanation that helped me understnad the problem right away!
    Regards,
    svenXY

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2015-07-03 03:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (48 votes), past polls