in reply to checking the matches

What did you try so far? It's not really complicated, but you won't learn anything unless you try it yourself.

And that's what perlmonks is good for: help you learning, not writing your code.

Two small hints: take a look at split, and consider storing one of your arrays in a hash.