<?xml version="1.0" encoding="windows-1252"?>
<node id="421253" title="Genbank file parsing" created="2005-01-11 07:08:47" updated="2005-06-01 20:34:22">
<type id="115">
perlquestion</type>
<author id="961">
Anonymous Monk</author>
<data>
<field name="doctext">
Dear monks,
My question is related to file parsing within while loops.  I have a large file containing many individual files all in the same format. &lt;P&gt;I want to extract certain features from each file which mainly is easy.  My problem is when I need to extract everything between two markers in the file.  I am struggling to get all the nice info between ORIGIN and // in each file.&lt;P&gt;  This is how the file looks: How can I extract all the info between ORIGIN and // for each record??

&lt;code&gt;
# extract of file:  
#===============

FEATURES             Location/Qualifiers    
                     /note="blah blah"   
COUNT                200
ORIGIN
        1 lots of nice info
       61 lots of nice info
      121 lots of nice info
   
//
&lt;/code&gt;

This is my code so far:
&lt;code&gt;
open (FILE, $ARGV[0]) or die "unable to open FILE\n";
                                                                                                                
my ($note, $info, $features,$count);
my ($c,$d);
my @seq;
my $in_seq = 0;
my $seq = '';
                                                                                                                
while (&lt;FILE&gt;)     {
        my $line = $_;
      
        if ($line =~ /(FEATURES)\s+(\w+)/)   {
                $features = $2;
        }
        if ($line =~ /(COUNT)\s+(\d+)/)   {
                $count = $2;
        }
    
        if ($line =~ /^ORIGIN/)   {
        #        print "$line\n";
                push @seq, "$line\n";
        }     
        until ($line =~ /\/\/) {}; 
}
                                                                                                                
print "@seq\n";
&lt;/code&gt;

&lt;p&gt;&lt;small&gt;Retitled by [davido].&lt;/small&gt;&lt;/p&gt;

</field>
<field name="reputation">
11</field>
</data>
</node>
