in reply to Search hash keys using values from array

I would use reverse for this:

my @array = qw(world today is very nice); my %hash = (0 => "Hello", 1=> "world" , 2=> "today" , 3=> "is" , 4=> " +nice" ); my %reversed_hash = reverse %hash; foreach my $word ( @array ) { if ( exists $reversed_hash{ $word } ) { print $reversed_hash{ $word } . "\n"; } else { print "unknown '$word'\n"; } }

Output:

1 2 3 unknown 'very' 4