blob: 6a00200b50c3e7a8d9697895a77c5a5fba774a46 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#!/Perl/bin/perl
use strict;
use warnings;
$| = 1; #flush output
my %words = ("fred", "Kamel",
"barney", "Lama",
"betty", "Auster",
"wilma", "Auster" );
my ( $name, $guess, $secretword );
print "Wie heissen Sie? ";
$name = <STDIN>;
chomp $name;
if ( $name eq "gerhard" ) {
print "Hallo Gerhard, wie nett dass du da bist!\n";
}
else {
print "Hallo $name!\n"; # Standard Gru�
# mit exists kann man ueberpruefen ob ein Schluessel in einem Hash vorhanden
# ist
if( exists $words{$name} ){
$secretword = $words{$name} ; # Passwort holen
}
else {
$secretword = "groucho"; # f�r alle die kein Passwort haben
}
print "Wie lautet das Geheimwort? ";
$guess = <STDIN>;
chomp ( $guess );
while ( $guess ne $secretword ) {
print "Falsch geraten, nochmal. Wie lautet das Geheimwort? ";
$guess = <STDIN>;
chomp $guess;
}
}
|