in reply to How can you check if a word in a array occur in another array?

This line:

@words = split(/ /, $word);

... replaces the @words array each time around the loop. So when you're finished looping, @words will only contain words from the last line of the file, words from the previous lines having been discarded.

What you want is:

push @words, split(/ /, $word);

I leave @EN = split(/ /, $word) as an exercise for the reader.

Also, I concur with frozenwithjoy in that a hash is more likely to suit your needs than an array.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'