Something else is wrong:
Either $sentence doesn't contain what you think it does, or you haven't run the code you posted. Or you need the /m flag. Or something else.>perl -demo Loading DB routines from perl5db.pl version 1.28 Editor support available. Enter h or `h h' for help, or `perldoc perldebug' for more help. main::(-e:1): mo DB<1> $sentence = 'sdfsdfsdf foo asdfklj bar ;alkdjdf' DB<2> x $sentence 0 'sdfsdfsdf foo asdfklj bar ;alkdjdf' DB<3> p "match" if $sentence =~ /foo/ && $sentence =~ /bar/ match
Please post the actual code (or better, a minimal example that behaves the same way), including the value of the variable involved in the match.
-QM
--
Quantum Mechanics: The dreams stuff is made of
In reply to Re: using && with regex in an if() statement
by QM
in thread using && with regex in an if() statement
by Tachoknight
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |