This could be done using Parse::RecDescent. For example, here is a simple, stripped-down grammar for part of a play. I used 'autotree' so you would get a parse tree automatically. You can either write code to work with the parse tree itself, or define your own actions for each grammar rule so that the play information can go into a hash for each player.
use strict; use Parse::RecDescent; use Data::Dumper; # ORL 13 Sauls kicked off 71 yards from the ORL30 my $grammar = q { <autotree> file : play(s) play : side number player action action : kick | run kick : 'kicked off' number 'yards from the' sideyard run : 'ran' number 'yards' side : /\w+/ player : /\w+/ number : /\d+/ sideyard : /\w+\d+/ }; my $parser = new Parse::RecDescent ($grammar); my $ret = $parser->file("ORL 13 Sauls kicked off 71 yards from the ORL +30"); print Data::Dumper->Dump([$ret], [qw(ret)]);

In reply to Re: Parsing a Log File by tall_man
in thread Parsing a Log File by PrimeLord

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.