my %listA; @listA{@a}=(); foreach my $item ( @b ) { next if exists $listA{$item}; push @c, $item; }