in reply to Unique elements in an array

FAQ. See How can I remove duplicate elements from a list or array?

But maybe this will help:

my %name_of_id; for my $id ( @all_ids ) { if ( ! exists $name_of_id{$id} ) { my $name = get_name_of_id($id); # whatever $name_of_id{$id} = $name; } }

This could be more compactly written as

$name_of_id{$_} ||= get_name_of_id($_) for @all_ids;
but only if names are guaranteed to have non-false values.

We're building the house of the future together.