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] ;
sub has_won - grep with adverbial block
incfile 'p6.has_won';
sub guess()
incfile 'p6.sub_guess';
sub draw_if_greater_than - constants, ternary operator
sub draw_if_greater_than (Str $char, Int $num) returns Bool {
($number_of_bad_guesses >= $num) ?? $char :: ' ';
The character for blank should be a constant, e.g.:
my ($BLANK) is constant = ' ';
but it is not implemented yet.
sub draw_hangman - function interpolation
incfile 'p6.sub_draw_hangman'
main loop - new repeat operator
"x"
in p5 is now "xx"
in p6
@solution = ('' xx +@letters);
The Whole Program
incfile 'hangman.p6'
Credits
- author: Terrence Brannon
- Substantial #perl6 help from
mauke, ninereaons, revdiablo, autrijus, stevan
- perl6-language help from Ashley Winters