Use eval to cache the substitution in an anonymous sub:
use strict;
use warnings;
# Cached Regex's: LHS, RHS, Modifiers
my @re_rules = (
['(?:this|or|that)', 'bob', 'gsi'],
['(?:One|Two|Three)', 'Four', 'gs'],
);
my @re_subs = map {
my $sub = eval "sub { s/$_->[0]/$_->[1]/$_->[2] for (\@_)}";
die $@ if $@;
$sub;
} @re_rules;
my @strings = ('this one or that other', 'One two Three');
for my $string (@strings) {
$_->($string) for (@re_subs);
print "$string\n";
}
Or just declare the anonymous subs yourself if you don't need the special markup:
use strict;
use warnings;
my @re_subs = (
sub { s/(?:this|or|that)/bob/gsi for (@_) },
sub { s/(?:One|Two|Three)/Four/gs for (@_) },
);
my @strings = ('this one or that other', 'One two Three');
for my $string (@strings) {
$_->($string) for (@re_subs);
print "$string\n";
}