in reply to Matching quoted variables. Cant make it work..
Let's go into details...
qq/$a/ =~ qq/$b/ is equivalent to
"$a" =~ "$b" (because qq// and "" are the same quoting operator), and to
$a =~ "$b" (because a match already forces the stringification of its left hand side), and to
$a =~ $b (because a match already forces the stringification of its right hand side if it's not a compiled regexp), and to
$a =~ /$b/ (because strings on the right hand side of a match are treated as regexp), and to
$a =~ /MIN.(NERR_VOL2)/ (because we know the value of $b).
But remember that ., ( and ) are special characters in regexps.
If you wanted to check for equality, you want
$a =~ /^\Q$b\E\z/
or the faster
$a eq $b
If you wanted to check for "$b is in $a", you want
$a =~ /\Q$b/
or the faster
index($a, $b) >= 0
By the way,
qq/$a/ eq qq/$b/ is equivalent to
"$a" eq "$b" (because qq// and "" are the same quoting operator), and to
$a eq $b (because eq already forces stringification of its args).
|
|---|