in reply to Regexp substitution using variables
You need to add the modifiers at the start of the substitution like this:
This will print:use strict; my $pattern = 'test'; my $replacement = 'New'; my $flags = 'i'; my $value = 'My Test Text'; $value =~ s/(?$flags)$pattern/$replacement/; print "$value\n";
My New Test
|
|---|