Perl практика



              

Несколько секретных слов.


#!/usr/local/bin/perl -w @words = qw(camel lama aplaca); # Perl 5.004 print "What is you name? "; $name = <STDIN&gt ; chomp($name); if($name eq "German") { print "Hello, German! Good of you to be here!\n"; } else { print "Hello, $name! \n"; print "What is the secret word? "; $guess = <STDIN&gt ; $i = 0; $correct = "maybe"; while($correct eq "maybe") { if($words[$i] eq "guess) { $correct = "yes"; } elsif($i &lt 2) { $i = $i + 1; } else { print "Wrong, try again. What is the secret word? "; $guess = <STDIN&gt ; chomp($guess); $i = 0; } } }




Содержание  Назад  Вперед