title: Perl: find if a variable's value matches that in an array
body: <p>I'm a perl newbie. I have a code in which a variable is loaded with several values during a foreach loop. What I want to do is to perform some operation on that variable only if its in that array. What is the <strong>most efficient</strong> way to do this in perl as the data I am working on is very large.</p>
  
  <p>A simple example of my question is, say I have an array of fruits I want</p>
  
  <pre><code>@fruits_i_like = qw (mango banana apple);
  </code></pre>
  
  <p>But I have a $fruit variable in a foreach loop which gets the name of fruits from a data file that has all different types of fruits. How would I pick only those cases of $fruit that are in my @fruits_i_like array?</p>