Em Sáb, 2008-12-27 às 04:29 -0800, Ovid escreveu: > I'm trying to replicate the following behavior in Perl 6, but can't > figure out a "natural" way to do this (the task is filling in guessed > letters for a hangman game):
> while ( $word =~ /$letter/g ) { > $guess[ pos($word) - 1 ] = $letter; > } > What would be the "canonical" Perl 6 way of doing this? Preferably > one which works with the current state of Rakudo :) In Perl 6, such features are available through the match object, named $/; The method you're looking for is $/.from. Unfortunally, rakudo doesn't seem to support match-in-while semantics, but follows a preview of something that does work... my $word = 'banana'; my @guess = <? ? ? ? ? ?>; $word ~~ /a/; @guess[$/.from] = 'a'; say @guess; daniel