From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- .../examples/EXAMPLE9.PL | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Bachelor/Systemprogrammierung in Perl/examples/EXAMPLE9.PL (limited to 'Bachelor/Systemprogrammierung in Perl/examples/EXAMPLE9.PL') 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 = ; +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 = ; + chomp ( $guess ); + + while ( $guess ne $secretword ) { + print "Falsch geraten, nochmal. Wie lautet das Geheimwort? "; + $guess = ; + chomp $guess; + } + print "Hallo $name, der Zugang ist erlaubt\n"; +} +exit; + + + + + + + -- cgit v1.2.3