in reply to Regex false match

because || matches. You need to quote the match string if you are trying to match it verbatim:

if ($line =~ m|\Q$process\Q|i) {

DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: Regex false match
by mhearse (Chaplain) on Dec 19, 2006 at 02:10 UTC
    Many thanks.

      Grandfather meant \Q..\E, not \Q..\Q.

      if ($line =~ m/\Q$process\E/i) {

      That checks if $process is in $line. You could also use index, which might even be faster.

      if (index(lc($line), lc($process)) >= 0)) {

      If you wanted to check if the two vars are the same, then that should be

      if ($line =~ m/^\Q$process\E\z/i) {

      or

      if (lc($line) eq lc($process)) {