title: parse multiple lines in perl regular expression and extract value
body: <p>I am a beginner in perl. I have a text file with text similar to as below. i need to extract VALUE="&lt;<strong>NEEDED VALUE</strong>>". Say for SPINACH, i should be getting SALAD alone.</p>
  
  <p>How to use perl regex to get the value. i need to parse multiple lines to get it. ie between each #ifonly --- #endifonly</p>
  
  <blockquote>
    <p>$cat check.txt    </p>
  </blockquote>
  
  <pre><code>while (&lt;$file&gt;)
  {
     if (m/#ifonly .+ SPINACH .+ VALUE=(")([\w]*)(") .+ #endifonly/g)
  {
      my $chosen = $2;
     }
  }
  </code></pre>
  
  <p><br></p>
  
  <pre><code>#ifonly APPLE CARROT SPINACH
  VALUE="SALAD" REQUIRED="yes" 
  QW RETEWRT OIOUR
  #endifonly
  #ifonly APPLE MANGO ORANGE CARROT
  VALUE="JUICE" REQUIRED="yes" 
  as df fg
  #endifonly
  </code></pre>