title: Perl compare array content to hash values
body: <p>I'm trying to check the existence of words from a file in a hash, and if so to display the corresponding hash key and value.</p>
  
  <p>So far, I've been able to do it with an array <code>@motcherches</code> which values are given in the script.</p>
  
  <p>I can't find a way to give as values to this array words from a external file (here <code>FILEDEUX</code>). 
  Could you point me in the right direction?</p>
  
  <p>(Please don't hesitate to correct my way of explaining my problem.)</p>
  
  <pre><code>#!/usr/bin/perl
  use v5.10;
  use strict;
  use warnings;
  my $hashtable = $ARGV[0];
  my $textecompare = $ARGV[1];
  open FILE,"&lt;$hashtable" or die "Could not open $hashtable: $!\n";
  open FILEDEUX,"&lt;$textecompare" or die "Could not open $textecompare: $!\n";
  
  
      while ( my $line = &lt;FILE&gt;)
      {
          chomp($line);
          my %elements = split(" ",$line);
  
          my @motcherches = qw/blop blup blip blap/;
          foreach my $motcherches (@motcherches) {
  
              while ((my $key, my $value) = each (%elements)) {
                  # Check if element is in hash :
                  say "$key , $value" if (exists $elements{$motcherches}) ;
              }
          }
      }
  
  close FILE;
  close FILEDEUX;
  </code></pre>
  
  <p>EDIT: Example inputs</p>
  
  <p><code>FILE</code> (transformed into <code>%elements</code> hash)</p>
  
  <pre><code>Zieler player
  Chilwell player
  Ulloa player
  Mahrez player
  Ranieri coach
  </code></pre>
  
  <p>============================================================================</p>
  
  <p><code>FILEDEUX</code> (transformed into <code>motcherches</code>array)</p>
  
  <p>One save is quickly followed by another, and this time Zieler had to be a little sharper to keep it out.
  Izaguirre gives Mahrez a taste of his own medicine by beating him all ends up down the left flank, although the Leicester winger gave up far too easily.
  Claudio Ranieri will be happy with what he has seen from his side so far.</p>
  
  <p>=============================================================================</p>
  
  <p>Expected output:</p>
  
  <pre><code>Zieler player
  Mahrez player
  Ranieri coach
  </code></pre>