in reply to unique elements in an array

I just run a check using something like:
my @set = qw(1 2 3 4 5 6); my @add_to_set = qw(5 6 7 8 9); # note dupes.........^ ^.... foreach (@add_to_set) { if (!is_member($_,@set) { push(@set,$_); } else { warn "duplicate member detected...\n"; } } sub is_member { my $self = shift; my $test = shift; my $ret = 0; foreach (@_) { if ($test eq $_) { $ret++; last; } } return $ret; }
As far as I know, there are no native set functions like intersect, union, etc, but these can be easily created with what is available.