use warnings; use strict; my @array = qw(Julia_Roberts(1,5) Cintheia Chelsia Rohan); my $pattern = 'Julia_Roberts'; my $change = 'Cintheia'; # Find your pattern my ($found) = grep /$pattern/, @array; # Change your pattern into the new value $found =~ s/$pattern/$change/; # Replace the change item with your new value for (@array) { s/$change/$found/; } print map "$_\n", @array;