It seems like the only way is to reinforce RE, replace (-i) with (i-), and re-quote it back:
my $pat = qr/F(o+)B(a+)r/; my $str = "$pat"; $str =~ s/(?<!\\)(\(\?\w*)-([^i:]*)i([^i:]*):/$1i-$2$3:/g; $pati = qr/$str/;
UPDATE: perl 5.14 quotes regexps in a different way , so my example should look like
my $pat = qr/F(o+)B(a+)r/; my $str = "$pat"; $str =~ s/(?<!\\)\(\?\^/(?^i/g; $pati = qr/$str/;
But I do not have perl 5.14 on hand and I can not test it.
UPD2: I also could not check the open bracket.
source share