Doesn't work. Try the following test:
my @array1 = qw(dog cat rat mouse);
my @array2 = qw(dog rat mouse bird);
my @array3 = qw(cat rat fish mouse);
my %seen;
my @collection;
foreach my $item ( @array1, @array2, @array3 )
{
unless ( exists( $seen{$item} ) )
{
push @collection, $item;
$seen{$item}++;
}
}
print "@collection\n";
@collection = ();
%seen = ();
foreach my $item ( @array2, @array1, @array3 )
{
unless ( exists( $seen{$item} ) )
{
push @collection, $item;
$seen{$item}++;
}
}
print "@collection\n";
__END__
Prints:
dog cat rat mouse bird fish
dog rat mouse bird cat fish
Theoretically, it should always give the same order, no matter what order the initial arrays are in.
------
We are the carpenters and bricklayers of the Information Age.
Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.
|