模式匹配操作符=~、!~
=~检验匹配是否成功:$result = $var =~ /abc/;若在该字符串中找到了该模式,则返回非零值,即true,不匹配则返回0,即false。!~则相反。
这两个操作符适于条件控制中,如:
if ($question =~ /please/) {
print ("Thank you for being polite!\n");
}
else {
print ("That was not very polite!\n");
}