use warnings; use strict; my @a = ("a=1", "b=2", "c=3"); for my $e (grep /^b=/, @a) { $e = "b=22"; } print join(",", @a);