title: Perl- Extract each line from a txt file and store into different variables
body: <p>I readin a txt file using a perl script, but im wondering how to store each line from the txt file into a different variable in the perl script using pattern matching. I can match a line using ~^>gi , but it displays both lines from the txt file with >gi (i.e line 1 &amp; 3), also i want to read the two separate DNA sequences into different variables. Consider my example below. </p>
  
  <p>file.txt</p>
  
  <pre><code> &gt;gi102939
   GATCTATC
   &gt;gi123453
   CATCGACA
  </code></pre>
  
  <p>the perl script:</p>
  
  <pre><code>#!/usr/local/bin/perl
  
  open (MYFILE, 'file.txt');
  
  @array = &lt;MYFILE&gt;;
  ($first, $second, $third, $fourth, $fifth) = @array;
  chomp $first, $second, $third, $fourth, $fifth;
  print "Contents:\n @array";
  
   if (@array =~ /^&gt;gi/) 
   {  
     print "$first";
   }
  
  close (MYFILE);
  </code></pre>