How can I find elements that are in one array but not another in Perl?

Viewed 4232

I have two arrays and I want to find elements that are in one array but not another:

ex:

@array1 = ("abc", "cde", "fgh", "ijk", "lmn")
@array2 = ("abc", "fgh", "lmn")

I need to end up with:

@array3 = ("cde", "ijk")
6 Answers
Related