Hi all

Another one with Parse::RecDescent:

If you want to get back a list of tokens from a grammar you have to do something like this:

use strict; use warnings; use Data::Dumper use Parse::RecDescent; use vars qw/@tokens/; my $p6 = Parse::RecDescent->new(q( letter : /\w/ character : letter { push @main::tokens, $item{letter}; } Format : character Format )); $p6->Format('abc'); die "Invalid pattern" unless (defined $p6); print Dumper \@tokens;

Is there any way to avoid the use of global variables for achieving this? I would like to feed the grammar with different input strings

Thanks in advance!

citromatik


In reply to scope issues in Parse::RecDescent by citromatik

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":