use strict; use warnings; my @list= qw(a b c a c); my $w="kandabbbc"; while (my $a=shift(@list)) { $w=~s/\Q$a//; @list = grep {!/\Q$a/} @list; } print $w; #### use strict; use warnings; my @list= qw(a b c a c); my $re = join '|', @list; my $w="kandabbbc"; $w=~s/$re//g; print $w;