sub draw_board - for, string concatenation

 
 
 
sub draw_board returns Str {  
    my $output = ''; 
    for (0 .. (+@letters - 1)) -> $i { 
        if (@letters[$i] ~~ rx:perl5{[-.,\s]}) { 
            $output ~= @letters[$i]; 
            @solution[$i] = @letters[$i]; 
        } 
        elsif (@solution[$i] ne '') { 
            $output ~= @solution[$i]; 
        } 
        else { 
            $output ~= '_'; 
        } 
    } 
    return $output; 
} 

  • We loop over the numbers which are the indices to the elements of the array @letters by forcing the array into numerical context:
        for (0 .. (+@letters - 1)) -> $i { 
    	
  • Now, ~= might throw you. You Perl 5'ers are seeing the regexp matching operator in reverse. But what you should be seeing is the Perl 6 string concatenation operator (~) followed by an equal sign. Which therefore means that
      $output ~= @letters[$i];  
    	
    translates to:
      $output = $output ~ @letters[$i] ;