
japhy
Enthusiast
/ Moderator
Jan 16, 2001, 1:36 PM
Post #2 of 7
(6625 views)
|
Either method is fine.
$safe = quotemeta $some{var}; if ($string =~ /$safe/) { ... } if ($string =~ /\Q$some{var}\E/) { ... } However, if you're just using them in regexes BY THEMSELVES, forget about that, and use eq or index() instead:
if ($string eq $some{var}) { # exact match } if (index($string, $some{var}) != -1) { # $some{var} is IN $string somewhere } Jeff "japhy" Pinyan -- accomplished hacker, teacher, lecturer, and author
|