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"; } }