Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: Issue with matching regex

by hippo (Bishop)
on Oct 20, 2022 at 08:32 UTC ( [id://11147536]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Issue with matching regex
in thread Issue with matching regex

The even better news is that the original if condition can be much simplified and by combining the first 2 regexen it can avoid the fully empty pattern into the bargain:

if ($line =~ /$var1|$var2/i && $check =~ /YES/i) { print "Inside if\n" +;} else {print "Outside if\n";}

Of course if we still have $var1 = '' then it will still match but that's a question for KishKishore as to what they actually intend.


🦛

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-03-29 01:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found