Using /e modifier to evaluate
#!usr/bin/perl use warnings; use strict; my $string = "abc ABC."; print "$string\n"; $string =~ s/(\bw\w+\b)/uc($1)/e; print "$string\n";