I think that's an excellent idea, especially given the general consistency of the format (only 210 is inconsistent in that it doesn't use a :, and then 400 is redundant in that it lists the seq id first). Here's my whack:
use strict; use warnings; my @one60s; my $two10; my $multilines = join '|', 223, 400; $multilines = qr/^$multilines$/; my $lastK; while(<DATA>) { chomp; if( /^< (\d+) > [^:]+ : \s* (.*) \Z/x or /^<(210)> SEQ ID NO (\d+) +/ ) { my( $k, $v ) = ( $1, $2 ); if( $k == 160 ) { $two10 = {}; push @one60s, $two10; } elsif( $k == 210 ) { $two10 = {}; push @{ $one60s[-1]->{210} }, $two10; } $lastK = $k; $two10->{$k} = $v; } else { $two10->{$lastK} .= "$_\n"; } } use Data::Dumper; local $Data::Dumper::Indent = 1; print Dumper( \@one60s ); eval { require YAML; YAML::DumpFile( __FILE__ . '.yaml', \@one60s ); } or die $@; __DATA__ <160> NUMBER OF SEQ ID NOS: 727 <140> CURRENT APPLICATION NUMBER: US/09/984,429 <210> SEQ ID NO 1 <211> LENGTH: 733 <212> TYPE: DNA <213> ORGANISM: Homo sapiens <400> SEQUENCE: 1 gggatccgga gcccaaatct tctgacaaaa ctcacacatg cccaccgtgc ccagcacct +g 60 aattcgaggg tgcaccgtca gtcttcctct tccccccaaa acccaaggac accctcatg +a 120 tctcccggac tcctgaggtc acatgcgtgg tggtggacgt aagccacgaa gaccctgag +g 180 tcaagttcaa ctggtacgtg gacggcgtgg aggtgcataa tgccaagaca aagccgcgg +g 240 aggagcagta caacagcacg taccgtgtgg tcagcgtcct caccgtcctg caccaggac +t 300 ggctgaatgg caaggagtac aagtgcaagg tctccaacaa agccctccca acccccatc +g 360 agaaaaccat ctccaaagcc aaagggcagc cccgagaacc acaggtgtac accctgccc +c 420 catcccggga tgagctgacc aagaaccagg tcagcctgac ctgcctggtc aaaggcttc +t 480 atccaagcga catcgccgtg gagtgggaga gcaatgggca gccggagaac aactacaag +a 540 ccacgcctcc cgtgctggac tccgacggct ccttcttcct ctacagcaag ctcaccgtg +g 600 acaagagcag gtggcagcag gggaacgtct tctcatgctc cgtgatgcat gaggctctg +c 660 acaaccacta cacgcagaag agcctctccc tgtctccggg taaatgagtg cgacggccg +c 720 gactctagag gat + 733 <210> SEQ ID NO 2 <211> LENGTH: 5 <212> TYPE: PRT <213> ORGANISM: Homo sapiens <220> FEATURE: <221> NAME/KEY: Site <222> LOCATION: (3) <223> OTHER INFORMATION: Xaa equals any of the twenty naturally ocurri +ng L-amino acids <400> SEQUENCE: 2 Trp Ser Xaa Trp Ser 1 5 <210> SEQ ID NO 3 <211> LENGTH: 86 <212> TYPE: DNA <213> ORGANISM: Artificial Sequence <220> FEATURE: <221> NAME/KEY: Primer_Bind <223> OTHER INFORMATION: Synthetic sequence with 4 tandem copies of th +e GAS binding site found in the IRF1 promoter (Rothman et al., Immunity 1:457-468 (1994)), 18 nucleotides complementary to the SV40 early promoter +, and a Xho I restriction site. <400> SEQUENCE: 3 gcgcctcgag atttccccga aatctagatt tccccgaaat gatttccccg aaatgattt +c 60 cccgaaatat ctgccatctc aattag + 86 <210> SEQ ID NO 86 <211> LENGTH: 194 <212> TYPE: DNA <213> ORGANISM: Artificial Sequence <220> FEATURE: <223> OTHER INFORMATION: Amplimer <400> SEQUENCE: 86 tgcttggtga aggaatagcc accccagaga aggagtatgg acttctatac acaatcatt +c 60 attcattcat tcattcattc attcattcat tcattcacta ctcatgcatg atctttgtc +c 120 ttatcttcct ccactgtcac atgaataccc acccactgca cctacctgct tcctattcc +t 180 gagaacccag gctc + 194 <210> SEQ ID NO 87 <211> LENGTH: 23 <212> TYPE: DNA <213> ORGANISM: Homo sapiens <400> SEQUENCE: 87 ggcaatggag gagttccggg aca + 23
It produces something like
$VAR1 = [ { '160' => '727', '210' => [ { '400' => '1 gggatccgga gcccaaatct tctgacaaaa ctcacacatg c +ccaccgtgc ccagcacctg 60 aattcgaggg tgcaccgtca gtcttcctct tccccccaaa acccaaggac accctcatg +a 120 tctcccggac tcctgaggtc acatgcgtgg tggtggacgt aagccacgaa gaccctgag +g 180 tcaagttcaa ctggtacgtg gacggcgtgg aggtgcataa tgccaagaca aagccgcgg +g 240 aggagcagta caacagcacg taccgtgtgg tcagcgtcct caccgtcctg caccaggac +t 300 ggctgaatgg caaggagtac aagtgcaagg tctccaacaa agccctccca acccccatc +g 360 agaaaaccat ctccaaagcc aaagggcagc cccgagaacc acaggtgtac accctgccc +c 420 catcccggga tgagctgacc aagaaccagg tcagcctgac ctgcctggtc aaaggcttc +t 480 atccaagcga catcgccgtg gagtgggaga gcaatgggca gccggagaac aactacaag +a 540 ccacgcctcc cgtgctggac tccgacggct ccttcttcct ctacagcaag ctcaccgtg +g 600 acaagagcag gtggcagcag gggaacgtct tctcatgctc cgtgatgcat gaggctctg +c 660 acaaccacta cacgcagaag agcctctccc tgtctccggg taaatgagtg cgacggccg +c 720 gactctagag gat + 733 ', '210' => '1', '211' => '733', '212' => 'DNA', '213' => 'Homo sapiens' }, { '400' => '2 Trp Ser Xaa Trp Ser 1 5 ', '222' => '(3)', '223' => 'Xaa equals any of the twenty naturally ocurring L-am +ino acids', '210' => '2', '211' => '5', '212' => 'PRT', '220' => '', '213' => 'Homo sapiens', '221' => 'Site' }, { '400' => '3 gcgcctcgag atttccccga aatctagatt tccccgaaat g +atttccccg aaatgatttc 60 cccgaaatat ctgccatctc aattag + 86 ', '223' => 'Synthetic sequence with 4 tandem copies of the GAS b +inding site found in the IRF1 promoter (Rothman et al., Immunity + 1:457-468 (1994)), 18 nucleotides complementary to the SV40 early promoter +, and a Xho I restriction site. ', '210' => '3', '211' => '86', '212' => 'DNA', '220' => '', '213' => 'Artificial Sequence', '221' => 'Primer_Bind' }, { '400' => '86 tgcttggtga aggaatagcc accccagaga aggagtatgg +acttctatac acaatcattc 60 attcattcat tcattcattc attcattcat tcattcacta ctcatgcatg atctttgtc +c 120 ttatcttcct ccactgtcac atgaataccc acccactgca cctacctgct tcctattcc +t 180 gagaacccag gctc + 194 ', '223' => 'Amplimer', '210' => '86', '211' => '194', '220' => '', '212' => 'DNA', '213' => 'Artificial Sequence' }, { '400' => '87 ggcaatggag gagttccggg aca + 23 ', '210' => '87', '211' => '23', '212' => 'DNA', '213' => 'Homo sapiens' } ], '140' => 'US/09/984,429' } ];

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.


In reply to Re: Re: Parse::RecDescent help by PodMaster
in thread Parse::RecDescent help by glwtta

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.