if ($b ne "" && $a =~ /$b/) { print "found"; } else { print "not found"; }