summaryrefslogtreecommitdiffstats
path: root/Bachelor/Systemprogrammierung in Perl/examples/EXAMPLE9.PL
diff options
context:
space:
mode:
authorSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
committerSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
commit33613a85afc4b1481367fbe92a17ee59c240250b (patch)
tree670b842326116b376b505ec2263878912fca97e2 /Bachelor/Systemprogrammierung in Perl/examples/EXAMPLE9.PL
downloadStudium-master.tar.gz
Studium-master.tar.bz2
add new repoHEADmaster
Diffstat (limited to 'Bachelor/Systemprogrammierung in Perl/examples/EXAMPLE9.PL')
-rw-r--r--Bachelor/Systemprogrammierung in Perl/examples/EXAMPLE9.PL55
1 files changed, 55 insertions, 0 deletions
diff --git a/Bachelor/Systemprogrammierung in Perl/examples/EXAMPLE9.PL b/Bachelor/Systemprogrammierung in Perl/examples/EXAMPLE9.PL
new file mode 100644
index 0000000..0f83d36
--- /dev/null
+++ b/Bachelor/Systemprogrammierung in Perl/examples/EXAMPLE9.PL
@@ -0,0 +1,55 @@
+#!/Perl/bin/perl
+use strict;
+use warnings;
+# in Perl kann man mit qw "Quote Words" die Initialisierung vereinfachen
+$| = 1; #flush output
+
+my %words = qw (fred Kamel
+ barney Lama
+ betty Auster
+ wilma Auster);
+
+my ( $name, $guess, $secretword, $original_name );
+
+
+print "Wie heissen Sie? ";
+$name = <STDIN>;
+chomp $name;
+
+$original_name = $name;
+$name =~ s/\W.*//; # alles hinter dem ersten Wort vergessen
+$name =~ tr/A-Z/a-z/; # alles in Kleinbuschstaben
+
+if ( $name eq "gerhard" ) {
+ print "Hallo Gerhard, wie nett, dass du da bist!\n";
+}
+else {
+ print "Hallo $original_name!\n"; # Standard Gruß
+
+ 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;
+ }
+ print "Hallo $name, der Zugang ist erlaubt\n";
+}
+exit;
+
+
+
+
+
+
+