The answer to your question very much depends on what sort of information you need to extract from the email. If you are merely extracting and testing standard fields in an email, there are som 130+ CPAN modules at your service. Surely at least one of them will have something you can use. (see http://search.cpan.org/search?m=dist&q=Email&s=1)

If you are trying to parse the body of the email as well, then the answer would depend on how the body of the mail is formatted. If it is a standard format (.ini, CSV, XML, HTML, YAML, etc), there is most likely a Perl module specifically for that format and you would be reinventing the wheel. If it is non-standard, the choice of parser depends on the grammar - it might be over kill, it might be just right, or it might just not fit the problem. Not every grammar can be parsed efficiently with Parse::RecDescent.

As for suggesting a grammar? The first step is describing the grammar in plain English and writing out some examples for yourself. Then you can work on converting the rules into the format needed by Parse::RecDescent or any other parsing tool you choose. The time to ask for help is after you've made a first pass on your own. Show us what you tried and we'll be glad to help clean up syntax problems or questions about how to represent some particularly troublesome formatting rule.

There are some great tips on how to be more exact in raising a question here: How (Not) To Ask A Question Please take the time to read it: We'd like to help you, but we can't read your mind or intuit your text formats and business rules off of a white board in your office.

Best, beth


In reply to Re: Parse::RecDescent question by ELISHEVA
in thread Parse::RecDescent question by fionbarr

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.