Created
May 23, 2012 19:43
-
-
Save cognominal/2777326 to your computer and use it in GitHub Desktop.
sprinting a Match, using a postfix 'for' instead of a block 'for' does not behave as expected.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub sprint( Match:D $m, $nm='TOP', $indent is copy = 0) { | |
sub i { ' ' x ($indent * 2) } | |
sub show(Str $s) { $s.substr(0, 30).perl; } | |
my $s = ''; | |
$s = i() ~ "$m.from() $m.to() $nm " ~ show( ~$m) ~ "\n"; | |
for $m.caps { | |
$s ~= sprint $_.value, $_.key, $indent++ if $_.value ~~ Match; # for $m.caps; | |
} | |
$s; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment