You can use Non-Matching Groups (? :) to accomplish this. For your code, I would try something like this:
if ($SDescription =~ m/((?:$sdescription_1))|((?:$sdescription_2))/gi) {
}
Whatever the “string” or pattern to display in $ 1 or $ 2. See Test Program below:
Testing program:
$str1 = "TEST1";
$str2 = "TEST2";
$str1 =~ /((?:TEST1))|((?:TEST2))/;
print "[$1] [$2]\n";
$str2 =~ /((?:TEST1))|((?:TEST2))/;
print "[$1] [$2]\n";
returns the results:
[TEST1] []
[] [TEST2]
source
share