sub test { local $_ = $_[0]; s/([a-z])/uc($1)/eg; return $_; } foreach (qw(a b c)) { print(test($_), "\n"); } $ perl script.pl A B C