my %backrefs; my( @backrefs ) = $with =~ /\$(\d+)/g; if ($modifiers =~ /g/) { $value =~ s/$this/ no strict 'refs'; @backrefs{@backrefs} = map { ${$_} } @backrefs; my $ret = $with; $ret =~ s'\$(\d+)'$backrefs{$1}'g; undef %backrefs; $ret; /ge; } else { ...