my $patt = join('|', map {"(\Q$_\E)"} @text_remove); my @tmp; s/^$patt//o ? $tmp[-1] .= $_ : push(@tmp,$_) for @xlate_data; @xlate_data = @tmp;