in reply to assigning arrays as values to keys of hash

It is possible to do exactly what you asked for by explicitly testing for duplicates (use the function 'none' from List::Util) before storing. Because it uses arrays, it does preserve the order of the features. This solution is probably the slowest running of all the suggestion you received.
?type pearllearner315.pl #!/usr/bin/perl use strict; use warnings; use List::Util qw(none); use Data::Dumper; my $file = \<<'EOF'; bird beak bird beak bird claw bird wings bird feathers snake fangs snake scales snake fangs snake tail EOF #my $file = 'file.txt'; open( FILE, '<', $file ) or die $!; my %hash; while ( <FILE> ) { chomp; my $lines = $_; my ($key, $value) = split(/\s+/, $lines, 2); push @{ $hash{$key} }, $value if none {$value eq $_} @{$hash{$key} +}; } print Dumper(\%hash); ?perl pearllearner315.pl $VAR1 = { 'snake' => [ 'fangs', 'scales', 'tail' ], 'bird' => [ 'beak', 'claw', 'wings', 'feathers' ] }; ?
Bill