Fellow mr mischief
I've never ever used Parse::RecDescent before. It worth the effort? The documentation is pretty big, seems that its a big and complex module. Except by some more regular expressions spread through the code, I'm basically using this as my "parser" (sorry about the portuguese comments, I can translate them on demand):

###################################################################### +##### package Netfax::Grammar; ###################################################################### +##### # $Id: Grammar.pm,v 1.3 2003/12/09 18:35:28 lcampos Exp $ use strict; use warnings; our( $VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS ); BEGIN{ use Exporter; $VERSION = do{my@r=(q$Revision: 1.3 $=~/\d+/g);sprintf"%d."."%02d"x$ +#r,@r}; use base qw( Exporter ); } @EXPORT_OK = qw( $command_line $subject_spec $telephone_list $option $option_spec $from_spec $domainname_spec $username_spec ); ###################################################################### +##### # Gramatica para capturar linha de comando (RFC822 "Subject:") my $time_spec = qr{ # Hora: dois digitos codificando numeros de 00 a 23. (?:[01]\d|2[0-3]) # Dois pontos, separador de hora/min, opcional. :? # Minutos: dois digitos, codificando minutos de 00 a 59 [0-5]\d}x; my $day_spec = qr{ # Dias de 01 a 09 0[1-9] | # Dias de 10 a 29 [12][0-9] | # Dias 30 e 31. 3[01] }x; my $month_spec = qr{ # Meses de 01 a 09 0[1-9] | # Meses 10, 11 e 12 1[012] }x; my $year_spec = qr{ # Seculo vinte, apenas 20 # Decadas: de 03 a 99. (?:0[3-9]|[1-9]\d) }x; my $date_sep = qr{ # Separadores validos sao '.' e '-'. (?:\.|-) }x; my $date_spec = qr{ # Dia, de 01 a 31. $day_spec # Separador de data, opcional. $date_sep? # Mes, de 01 a 12. $month_spec # Separador de data, opcional. $date_sep? # Ano, de 2003 a 2099. $year_spec }x; our $option = qr{ # Todas as opcoes comecam com '/' / (?: # IMO ou IM [Ii][Mm][Oo]? | # NSIM ou SIM [Nn]?[Ss][Ii][Mm] | # D (data) [Dd]$date_spec | # H (hora) [Hh]$time_spec ) }x; # Captura o valor passado como argumento em algumas opcoes. our $option_spec = qr{ # Todas as opcoes comecam com '/' / (?: # IMO ou IM ([Ii][Mm][Oo])? | # NSIM ou SIM ([Nn]?[Ss][Ii][Mm]) | # D (data) [Dd]($date_spec) | # H (hora) [Hh]($time_spec) ) }x; my $option_list = qr{ # lista de opcoes: (?: # uma opcao $option # seguida de zero ou mais espacos \s* # tantas vezes quantas se puder encontrar. )* }x; my $phone = qr{ (?: # Caracteres '-', '+', '(', ')', '.', '0-9', # 'a-z', 'A-Z', '_' [-+\(\)\.\w] # ou | # todo espaco em branco (' ') nao seguido de virgula \ (?!,) # obrigatoriamente uma vez, e # tantas mais quantas voce conseguir. )+ }x; my $phone_list = qr{ $phone(?:(?:\s*,\s*)$phone)* }x; # Linha de comando: captura a lista de telefones # e a lista de opcoes separadamente. our $command_line = qr{($phone_list)\s*($option_list)}x; our $subject_spec = qr{^[Ss][Uu][Bb][Jj][Ee][Cc][Tt]:\s*$command_line} +x; # Fim das Regras ###################################################################### +##### ###################################################################### +##### # Regras para capturar telefones de uma lista de telefones our $telephone_list = qr{($phone)(?:\s*,\s*)?}x; # Fim das Regras ###################################################################### +##### ###################################################################### +##### # Regras para capturar o RFC822 "From:" de um email our $username_spec = qr{ # Username [A-Za-z0-9_.-]+ }x; our $domainname_spec = qr;(?:$username_spec\.)+[A-Za-z]{2,4};x; our $from_spec = qr{ $username_spec # "at" @ $domainname_spec }x; # Fim das Regras ###################################################################### +##### 1;__END__

I would love to read what the fellow monks think about this code, and if someone have any nice way to improve it. Thank you all for the answers and considerations, and may the gods bless you.


"In few words, translating PerlMonks documentation and best articles to other languages is like building a bridge to join other Perl communities into PerlMonks family. This makes the family bigger, the knowledge greather, the parties better and the life easier." -- monsieur_champs


In reply to Re: Re: Re: Re: Many birds, single cage... by monsieur_champs
in thread Many birds, single cage... by monsieur_champs

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.