sub foo_ize { for my $val (@_) { $val =~ s!bar!foo!gi; }; }; my @arr = qw( baz bar baz BarBar ); foo_ize @arr; print join ",", @arr;