note
bart
Remove the slashes, extract the modifier ("i") (say, in a variable $flags). Keep the core of the regex as a string, in your example that would be <code>.*uba$</code>.
<p>Then put "(?$flags:" in front of it, and ")" behind it. You can use that string ($re) directly as a regex:
<strike><code>
$re = "(?:$flags:$core)";
if($input =~ $re) { ... }
</code></strike>
<b>edit</b> Oops, one too many colons:
<code>
$re = "(?$flags:$core)";
if($input =~ $re) { ... }
</code>
You can also turn it into a regex object:
<code>
$qr = qr/$re/;
</code>
1208734
1208734