in reply to Parse grammar via RecDescent parser
The docs say that ... the use of $this...->{local} is always safe. You will have to reset this field if you plan to call the same parser multiple times and you don't want each run to add its items to those of the previous runs. And, of course, nothing prevents you from using local for storing more complicated data structures.#!/usr/bin/env perl use strict; use warnings; use Parse::RecDescent; use Data::Dumper; my $grammar = <<'END'; foo: word(s) word: /\S+/ { push @{$thisparser->{local}}, lc $item[1]; $return = uc $item[1]; } END my $parser = Parse::RecDescent->new($grammar); my $what = $parser->foo("Foo bAr baZ"); print Dumper $what, $parser->{local}; __END__ $VAR1 = [ 'FOO', 'BAR', 'BAZ' ]; $VAR2 = [ 'foo', 'bar', 'baz' ];
This said, I suggest that you read Corion's advices again. It seems like you're trying to mix parsing and evaluation, which might not be the wisest thing to do.
perl -ple'$_=reverse' <<<ti.xittelop@oivalf
Io ho capito... ma tu che hai detto?
|
---|