Skip to content

Commit 059fa13

Browse files
authored
hangman: consistently handle eof (#842)
* If you reach the end of a game and see the PLAY AGAIN prompt, eof will cause the program to terminate * Do the same if eof occurs after the GUESS A LETTER prompt; the NetBSD version handles this in getguess() [1] * test: echo sword > wordlist.txt && echo hi | perl hangman # now terminates 1. http://cvsweb.netbsd.org/bsdweb.cgi/src/games/hangman/getguess.c?annotate=1.10
1 parent 1aaf645 commit 059fa13

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

bin/hangman

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ while( $cont =~ /^y/io ) {
3434
while( ($num_wrong < 6) && ($num_corr < $tot_letters) ) {
3535
print "\nEnter a letter: ";
3636
$letter = <STDIN>;
37+
exit unless defined $letter;
3738
chomp( $letter );
3839
$letter = lc( $letter );
3940
if( $letter =~ /^[a-z]$/o ) {

0 commit comments

Comments
 (0)