summaryrefslogtreecommitdiffstats
path: root/Bachelor/Systemprogrammierung in Perl/examples/EXAMPLE3.PL
blob: 70ff194abd16a5af0ee13c5e2389c108b76496b6 (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
#!/Perl/bin/perl

use strict;
use warnings;
$| = 1; #flush output

my ( $secretword, $name, $guess );

$secretword = "Lama"; #unser Geheimwort
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�
    print "Wie lautet das Geheimwort? ";
    $guess = <STDIN>;
    chomp ( $guess );

# Perl kennt auch eine while Anweisung fuer die abweisende Schleife
# Der Operator ne vergleicht zwei Strings auf Ungleicheit

    while ( $guess ne $secretword ) {
	print "Falsch geraten, nochmal. Wie lautet das Geheimwort? ";
	$guess = <STDIN>;
	chomp $guess;
    }
}
exit;