$comm = '(xyz'; $line = '123(xyz)456'; if ($line =~ /$comm/) { #error! same as $line =~ /(xyz/ which has an unmatched '(' # do stuff } if ($line =~ /\Q$comm/) { #no error! same as $line =~ /\(xyz/ -- '(' is escaped # do stuff }