my $p6 = Parse::RecDescent->new(q( letter : /\w/ character : letter Format : character(s) )); my $x= $p6->Format('abc'); die "Invalid pattern" unless (defined $p6); print Dumper $x; #prints $VAR1 = [ 'a', 'b', 'c' ];

Be careful to specify what a rule returns with $return if more than one production is in a rule (i.e. with a rule like "strangeword: character number character(s)", since only the last production is returned as a default

With $return you can also return anything you want, i.e. parsed and interpreted commands, hashes, objects ...


In reply to Re: scope issues in Parse::RecDescent by jethro
in thread 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":