in reply to Applying a RegEx in a variable
You could also eval it directly - depends on your application
However this doesn't provide you with access to the regex variables (like $&, $1, $', ...) as they are dynamically scoped - imagine the eval being a separate block of code.# eval returns the value of the last evaluated expression if (eval "\$String =~ $RegEx") { print "Matched"; } else { print "Not matched"; }
From your post I'm not sure if you are aware of the difference between eval BLOCK and eval EXPR so I'd suggest reading up on that ...
-- Hofmator
|
---|