in reply to $variable as regex in s///
But I wanted to point out something else ...
Is there a good reason that you're using the "evaluate" flag? (the e of ge) Because, if not, you may just have wanted:
$string =~ s/$regex/'bar'/g; # This will print ... "this is a 'bar'" # but with "/ge" .... "this is a bar"
It took me a moment to figure out why the output didn't contain apostrophes!
|
|---|