summaryrefslogtreecommitdiffstats
path: root/Bachelor/Systemprogrammierung in Perl/examples/EXAMPLE3.PL
diff options
context:
space:
mode:
Diffstat (limited to 'Bachelor/Systemprogrammierung in Perl/examples/EXAMPLE3.PL')
-rw-r--r--Bachelor/Systemprogrammierung in Perl/examples/EXAMPLE3.PL31
1 files changed, 31 insertions, 0 deletions
diff --git a/Bachelor/Systemprogrammierung in Perl/examples/EXAMPLE3.PL b/Bachelor/Systemprogrammierung in Perl/examples/EXAMPLE3.PL
new file mode 100644
index 0000000..70ff194
--- /dev/null
+++ b/Bachelor/Systemprogrammierung in Perl/examples/EXAMPLE3.PL
@@ -0,0 +1,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;