in reply to checking the matches
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.