in reply to Calling a function in regex substitution

For this particular example, you don't need a function call: just use \U to convert the rest of the string (up to \E or an overriding modifier) to uppercase.

If you want to replace all matches, you'll have to specify the /g flag too.

$str=~s/(iteration)(.*)/<B> \U$1\E$2 <\/B>/g;

You can run code in the substitution part by specifying the /e flag, but you'll have to make sure the whole string on the right is valid Perl code. You can't mix and match literal strings and executable code.

$str=~s/(iteration)(.*)/"<B> ".uc($1).$2." <\/B>"/ge;

The next works too, it's one of the few tricks available to embed executable code in a double-quoted string.

$str=~s/(iteration)(.*)/<B> @{[uc($1)]}$2 <\/B>/g;