Hello all,
 I was wondering if someone could explain lines: 14, 17, 18, 21, 27, and 43
please. I understand the bulk of the script. But to put it all
together would better.  Thanks so much!

1. #!/usr/bin/perl
2. # hangman.pl
3. use warnings;
4.
5.   @words = qw(internet cyber groups information);
6.   @guesses = ();
7.   $wrong = 0;
8.
9.   $answers = $words[rand @words];
10. $hangman = "0-|--<";
11.
12.  @letters = split(//, $answers);
13.  @hangman = split(//, $hangman);
14.  @blankword = (0) x scalar(@letters);
15.    OUTER:
16.       while ($wrong < @hangman) {
17.         foreach $i (0..$#letters) {
18.           if ($blankword[$i]) {
19.      print $blankword[$i];
20.     } else {
21.      print "-";
22.     }
23. }
24.  print "\n";
25.
26.         if ($wrong) {
27.         print @hangman[0..$wrong-1]
28.}
29.print "\n Your Guess: ";
30.    $guess = <STDIN>; chomp $guess;
31.        foreach(@guesses) {
32.           next OUTER if ($_ eq $guess);
33.}
34. [EMAIL PROTECTED] = $guess;
35. $right = 0;
36.       for ($i = 0; $i < @letters; $i++) {
37.          if ($letters[$i] eq $guess) {
38.            $blankword[$i]= $guess;
39.               $right = 1;
40.   }
41.}
42. $wrong++ if (not $right);
43. if (join('', @blankword) eq $answers) {
44.     print "You got it right!\n";
45.     exit;
46.   }
47. }
48. print "$hangman\nSorry, the word was $answers.\n";



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to