P6R is fun, but a little maddening, too. I see that I am going to have to learn Perl 6 more! Anyway, I am stumped why $0 doesn't contain three hash keys in the code below.
The input looks like this:
hEAD: one
DeCK: two
By: three
four I<five six>
BiO: seven
Shouldn't $0 have hash keys foo and deck?
use strict;
use Perl6::Rules -debug;
rule head :i { HEAD <COLON> }
rule deck :i { DECK <COLON> }
rule byline :i { BY <COLON> }
rule bio :i { BIO <COLON> }
rule body :w { <para> [<blankline> <para>]* }
rule para :w { <line>+ }
rule figure :i { }
rule line { <word>+? \v }
rule word { <italics> | <[\S+]>? }
rule italics :w { I <LANGLE> ([<word>|\v]+) <RANGLE> }
rule blankline { ^^$$ }
rule COLON { \: }
"abcd" =~ m/a $?foo:=(..) d/;
print "yes" if ($0->{foo} eq "bc");
$0->dump();
#
# get all input
my @line = <>; my $line = join('', @line);
if ($line =~
m:words/
<head> $?foo:=(<line>)
<deck> $?deck:=(<line>)
[<byline> $?by:=(<line>)]?
/)
{
$0->dump();
}