Why does this code work, as in print out the expected sequence ABCD, but if I add a print line to "character" it stops working? This code works:
use strict; use warnings; use Parse::RecDescent; my $grammar = q { start : character character character(s) {print "Found: ", $item[1], $item[2], join "", @{$item[3 +]}, "\n"; } character: /\w/ }; my $parser = Parse::RecDescent->new($grammar); defined $parser->start("ABCD") or die "didn't match";
However, the following code does not work:
use strict; use warnings; use Parse::RecDescent; my $grammar = q { start : character character character(s) {print "Found: ", $item[1], $item[2], join "", @{$item[3 +]}, "\n"; } character: /\w/ {print "Character: $item[1]\n"} }; my $parser = Parse::RecDescent->new($grammar); defined $parser->start("ABCD") or die "didn't match";
And by "not work" it prints out "1111" instead of the sequence:
Character: A Character: B Character: C Character: D Found: 1111
I sure that I am misunderstanding how RecDescent works. Can someone enlighten me? I'm using WinXP, the latest ActiveState perl, the latest RecDescent. BTW, this is a minor issue. But what's up with "chatterbox"? Why not use IRC like everyone else?

In reply to RecDescent help by ikaruga

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.