How can I find out, that whether a regular expression are matched or not(as a boolean)?!
tnx in advance.
$matchme = "some stuff";
if ( $matchme =~ m/[a-z]/ ) {
print "Oh snap you matched.";
}
By the number of matches found: 0 -> false, >=1 -> true:
zsh-4.3.9[sysadmin]% perl -le'print shift=~/OK/?"true":"false"' OK
true
zsh-4.3.9[sysadmin]% perl -le'print shift=~/OK/?"true":"false"' KO
false