in reply to Regex Substitution Evaluations

If the capture works, I'd use:
sub replace { my($text, $pattern, $replacement, $global) = @_; my $result = $text; if ($global) { $result =~ s/$pattern/$replacement/eg; } else { $result =~ s/$pattern/$replacement/e; } return $result; } my $y = replace($x, qr/\b(\w)/is, '"\U$1"', 1);

Keep in mind the 3rd argument is arbitrary Perl code instead of a string literal. It used to be able to include arbitrary Perl code, so nothing's new on the (lack of) security front.

If you really do want the options and/or regexp to be a string, I'd use my previously posted solution.