as smokemachine had asked, here's the translated code (so non-portuguese speakers can understand what's being printed as well)
this code is actually for beginners who aim to understand better what's being done on each part of the code. also, soon, it'll also be available for c and shell programs (who knows, someday, for pascal too... hehe).


/usr/bin/comenta
#!/usr/bin/perl our %parameters; while($para=shift) { $parameters{$1}=$2 if $para =~ /^--(.+)=(.+)$/; $parameters{file}=$para unless $para =~ /^--(.+)=(.+)$/; } find_language($file) unless our $language=$parameters{language}; our $file=$parameters{file}; our $level=0 unless $level=$parameters{level}; comment_code(); sub comment_code() { open(ARQ, $file) or die "File '$file' not found"; for(<ARQ>){ $lines++; $test=$_; chomp($test); unless($test =~ /^\s*#/) { open(RC, "/etc/comentarios") or die "Configuration file '/ +etc/comments' not found"; for(<RC>){ $_ =~ /<level=(\d)>/; $eni=$1; if($_ =~ /<$language>/i and $eni >= $level) { $_ =~ /<expr>(.+)<\/expr>/; $expre=$1; chomp($expre); $_ =~ /<coment>(.+)<\/coment>/; $comen=$1; chomp($comen); if($test =~ /$expre/) { @vector=split(/\[|\]/, $comen); $i=0; while($vector[$i]){ print $vector[$i].${$vector[$i+1]}; $i+=2; } print "\n"; $comments++; } } } } close RC; print $test."\n"; open(RC, "/etc/comentarios") or die "Configuration file '/ +etc/comments' not found"; for(<RC>){ if($_ =~ /<$language>/i and $_ =~ /<beginning>/i) { $_ =~ /<expr>(.*)<\/expr>/; $expre=$1; chomp($expre); $_ =~ /<coment>(.*)<\/coment>/; $comen=$1; chomp($comen); if($test =~ /$expre/) { @vector=split(/\[|\]/, $comen); $i=0; while($vector[$i]){ print $vector[$i].${$vector[$i+1]}; $i+=2; } print "\n"; $comments++; } } } close RC; } close ARQ; } sub find_language() { ($arq)=@_; $arq=~/.*\.([a-z]{1,2})/; $ext=$1; open(LIN, "/etc/comenta.conf") or die "Configuration file '/etc/co +menta.conf' not found"; for(<LIN>) { $a=$_; chomp($a); our $language=$1 if $a =~ /^(.*)=(\w{1,2},)*$ext,?(\w{1,2},?)* +$/; return() if $a =~ /^(.*)=(\w{1,2},)*$ext,?(\w{1,2},?)*$/; $language="" unless $a =~ /^(.*)=(\w{1,2},)*$ext,?(\w{1,2},?)* +$/; } close LIN; }

/etc/comentarios
<C><coment><level=1> # If formula '[1]' is true, it executes the ne +xt commands</coment> <expr>if\((.*)\)\ *\{</expr> <Perl><beginning><coment></coment> <expr>#\!\/usr\/bin\/perl</expr> <Perl><beginning><coment> ######################################### +############## </coment> <expr>#\!\/usr\/bin\/perl</expr> <Perl><beginning><coment> # Code commented by the script 'co +menta' # </coment> <expr>#!/usr/bin/perl</expr> <Perl><beginning><coment> # by Fernando Correa de Olivei +ra # </coment> <expr>#!/usr/bin/perl</expr> <Perl><beginning><coment> ######################################### +############## </coment> <expr>#!/usr/bin/perl</expr> <Perl><beginning><coment></coment> <expr>#!/usr/bin/perl</expr> <Perl><level=1><coment># If formula '[1]' is true, it executes the nex +t commands</coment> <expr>^\s*if\s?\((.*)\)\s*\{?</expr> <Perl><level=1><coment># If formula '[2]' is true, it executes command + '[1]'</coment> <expr>^\s*(.*)\ if\ ?\(?(.*)\)?\s?;</expr> <Perl><level=1><coment># Unless formula '[1]' is true, it executes the + next commands</coment> <expr>^\s*unless\ ?\(?(.*)\)?\ *\{</expr> <Perl><level=1><coment># Unless formula '[2]' is true, it executes com +mand '[1]'</coment> <expr>^\s*(.*)\ unless\ ?\(?(.*)\)?\ *;</expr> <Perl><level=1><coment># While expression '[1]' is true...</coment> <e +xpr>while\s?\((.*)\)\s?\{?</expr> <Perl><level=1><coment># For expression '[1]'</coment> <expr>for\s?\(( +.*)\)\s?\{</expr> <Perl><level=1><coment># '[1]' => the same as: '[2] = [2] + [3]'</come +nt> <expr>((\$\w)+\+=(\d+))</expr> <Perl><level=2><coment># Opens file '[2]' with the handle '[1]'</comen +t> <expr>open\((.*)\ ?\,\ ?(.*)\)</expr> <Perl><level=3><coment># Removes '\n' from the end of variable [1]</co +ment> <expr>chomp\((\$.*)\)</expr> <Perl><level=2><coment># Closes file with the handle '[1]'</coment> <e +xpr>close\(?\ ?(.*)\)?\ ?;</expr> <Sistema><level=1><coment> # User [1] with UID [3] and home [6]</co +ment> <expr>(.*):(x?):(.*):(.*):(.*):(.*):(.*)</expr> <Perl><level=1><coment># For each of the arguments of '[1]' do</coment +> <expr>foreach\ *\((.*)\)\ *{</expr> <Perl><level=1><coment># For [1] being the same as each one of the arg +uments in '[2]' do</coment> <expr>foreach\ *($.*)\ \((.*)\)\ ?{</expr +> <Perl><level=1><coment># '[1]' => from [2] to [3]</coment> <expr>(([0- +9]+)\ ?\.\.\ ?([0-9]+))</expr> <Perl><level=3><coment># '[1]' receives parameter passed on function c +all</coment> <expr>\((\$.*)\)=\@_</expr> <Perl><level=3><coment># [1] => '[2]' receives the first parameter pas +sed on program call, deleting it.</coment> <expr>((\$.*)=shift)</expr +> <Perl><level=1><coment># Declaration of local variable '[1]'</coment> +<expr>my\s*(\$\w*);</expr> <Perl><level=1><coment># Declaration of global variable '[1]'</coment> + <expr>our\s*(\$\w*);</expr> <Perl><level=1><coment># [1] => Declaration of local variable '[2]' co +ntaining '[3]'</coment> <expr>(my\s*(\$\w+)=(.*));</expr> <Perl><level=1><coment># [1] => Declaration of global variable '[2]' c +ontaining '[3]'</coment> <expr>(our\s*(\$\w+)=(.*));</expr> <Perl><level=1><coment># Declaration of local hash '[1]' </coment> <ex +pr>my\s*(\%\w+);</expr> <Perl><level=1><coment># Declaration of global hash '[1]'</coment> <ex +pr>our\s*(\%\w+);</expr> <Perl><level=1><coment># [1] => Value of position '[3]' in hash %[2]</ +coment> <expr>(\$(\w+)\{(.+)\})</expr> <Perl><level=1><coment># return() => Leaves the function</coment> <exp +r>return\ ?\(?\ ?\)?</expr> <Perl><level=1><coment># return([1]) => Leaves the function with '[1]' + as return value</coment> <expr>return\ ?\(?\ (.*)\ ?\)?</expr> <Perl><level=4><coment># As the function already says: Uses module '[1 +]'</coment> <expr>^use\s+(.+);</expr> <Perl><level=5><coment> ############################### Function '[ +1]' #######################</coment> <expr>^\s*sub (\w*\(?\)?)\ *\{?$ +</expr> <Perl><level=3><coment># [1] => Tests regular expression '[3]' in vari +able '[2]'</coment> <expr>\s?((\$\w+)\s?=~\s?(\/.+\/))</expr> <Perl><level=3><coment># [1] => Recognises any type of space, as white +space, tab or line break</coment> <expr>\s?\$\w+\s?=~\s?\/.*(\\s).*\/ +</expr> <Perl><level=3><coment># [1] => Recognises any letter</coment> <expr>\ +s?\$\w+\s?=~\s?\/.*(\\w).*\/</expr> <Perl><level=3><coment># [1] => Recognises any word</coment> <expr>\s? +\$\w+\s?=~\s?\/.*(\\W).*\/</expr> <Perl><level=3><coment># [1] => Recognises any number</coment> <expr>\ +s?\$\w+\s?=~\s?\/.*(\\d).*\/</expr> <Perl><level=3><coment># [1] => Recognises anything between '[2]' and +'[3]'</coment> <expr>\s?\$\w+\s?=~\s?\/.*(\[(\w|\d)\-(\w|\d)\]).*\/</ +expr> <Perl><level=3><coment># [1] => The expression '[2]' must appear betwe +en [3] and [4] times</coment> <expr>\s?\$\w+\s?=~\s?\/.*(([\[|\(].+[\ +]|\)])\{(\d),(\d)\}).*\/</expr> <Perl><level=3><coment># [1] => The expression '[2]' must appear betwe +en [3] and [4] times</coment> <expr>\s?\$\w+\s?=~\s?\/.*((\\.)\{(\d), +(\d)\}).*\/</expr>
(/etc/comenta.conf remains the same)
=)


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
grrr.... argh!

In reply to Re: Comment by mk.
in thread Comment by smokemachine

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.