perl, loop through an array of strings, substitute character, and save it back to an array

my @fields = ('Larry', 'Curly', 'Moe');

I want loop through the fields, replace all 'r' with 'R', and save it back to the same array @fields.
Who is Participating?
ozoConnect With a Mentor Commented:
s/r/R/g for @fields;
ishandoConnect With a Mentor Commented:
one way would be:

foreach $fld (@fields) { $fld =~ s/r/R/ig; }

rgbcofAuthor Commented:
Both works.  Thanks
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.