Using the following technique, you can encapsulate your regexes in anonymous subroutines, that can easily be called with the string to change as first argument. They return the changed string. Like this:
#list of regex-strings
my @regex =
(
's/(a+)/\U$1/g',
's/([bz]+)/XX/g',
);
#is now a list of subroutines
@regex = map { eval "\$sub = sub { \$_=\$_[0]; $_; \$_ }" } @regex;
This list can easily be used like this:
my @text =
(
"aaaabbzz",
"bbbyyy",
);
for my $t ( @text )
{
print "org $t\n";
for my $re ( @regex )
{
$t = &$re($t);
}
print "new $t\n";
}
Encapsulating the regexes in subroutines should be faster than recompiling the same regex again and again. Note, that I did no benchmarks.