in reply to How to apply modifiers to a substitution via variable?

use strict; use warnings; my $string = "aaaaaaaaa"; my $modifiers = "g"; eval "\$string =~ s/a/b/$modifiers;"; print $string;

Update: note that only question 1 was answered because only question 1 was asked at the time of posting. OP performed a substantive silent update subsequent to the initial create.


DWIM is Perl's answer to Gödel