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