use strict; use warnings; my @list1 = qw/education production results/; my @list2 = qw/education joe bob carl production steve results test/; print join "\n", notIn(\@list2, \@list1); sub notIn { my (@arr, %hash); @hash{@{$_[1]}} = (); for (@{$_[0]}) { push @arr, $_ if !exists $hash{$_}; } return @arr; }