use Test::More tests => 1; use Data::Dumper; 'cow' =~ / (?: # Grammar rules go here... (? .+ ) ){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 );