# build a regex to match just your keys my $removers = "^(?:" . join ("|", map { quotemeta $_ } @text_remove) . ") "; # print $removers out if you're not getting what you expect # strip the patterns from the beginning of each line. @xlate_data = map { s/$remove//; $_; } @xlate_data;