in reply to Add distinct elements to an array

One way (I've put the names in an array instead of a file):
my @source = qw(bob janne max max bob anne); my @finalnames; foreach $name (@source) { next if(grep(/^$name$/, @finalnames)); push @finalnames, $name; }
But as the list of names gets longer, it will be less efficient. SO use a hash:
my @source = qw(bob janne max max bob anne); my %temphash; my @finalnames; foreach $name (@source) { $temphash{$name} = 1; } @finalnames = (keys %temphash);