perlquestion
7stud
<p>Dear Monks,</p>
<p>Why the <deleted> does this code show an empty hash:</p>
<code>
use strict;
use warnings;
use 5.012;
use Parse::RecDescent;
$::RD_ERRORS = 1; #Parser dies when it encounters an error
$::RD_WARN = 1; # Enable warnings- warn on unused rules &c.
$::RD_HINT = 1; # Give out hints to help fix problems.
my %HASH;
my $grammar = <<'END_OF_GRAMMAR';
startrule : dir
{ $main::HASH{dir} = $item{dir} }
dir : 'hello'
END_OF_GRAMMAR
my $parser = Parse::RecDescent->new($grammar);
$parser->startrule("hello");
use Data::Dumper;
say Dumper(\%HASH);
--output:--
$VAR1 = {};
</code>