http://qs321.pair.com?node_id=795494

diotalevi has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, I think my grammar's thing rule should have captured $+{thing}. It didn't. What did I miss?

use Test::More tests => 1; use Data::Dumper; 'cow' =~ / (?: # Grammar rules go here... (?<thing> .+ ) ){0} # Invoke grammar here ^(?&thing) /x or die "Didn't match"; my $got = Dumper({ '%+' => {%+}, '@+' => [@+], '@-' => [@-], }); my $expected = Dumper({ '%+' => { thing => 'cow' }, '@-' => [ 0, 0 ], '@+' => [ 3, 3 ], }); is( $got, $expected );

Test results:

# Failed test at bin/ooga.pl line 24. # got: '$VAR1 = { # '%+' => {}, # '@-' => [ # '0' # ], # '@+' => [ # '1', # undef # ] # }; # ' # expected: '$VAR1 = { # '%+' => { # 'thing' => 'cow' # }, # '@-' => [ # 0, # 0 # ], # '@+' => [ # 3, # 3 # ] # }; # '