This shows you the differences between two versions of the page.
kurs:hashes [2014/09/10 21:22] |
kurs:hashes [2014/09/10 21:22] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | <code> | ||
+ | use strict; | ||
+ | use warnings; | ||
+ | my %teilnehmer = ( | ||
+ | guenther => 27, | ||
+ | christian => 22, | ||
+ | mario => 26, | ||
+ | martin => 26, | ||
+ | joachim => 30, | ||
+ | rudi => 23, | ||
+ | fritz => 50, | ||
+ | dennis => 39, | ||
+ | ); | ||
+ | |||
+ | $teilnehmer{'mark'} = 32; | ||
+ | |||
+ | # @ARGV | ||
+ | |||
+ | my $name = $ARGV[0]; | ||
+ | my $search_name = lc($name); | ||
+ | if (!$name) { | ||
+ | printf "usage: %s <name>\n", $0; | ||
+ | } elsif (exists $teilnehmer{$search_name}) { | ||
+ | printf "%s ist %s Jahre alt\n", | ||
+ | ucfirst(lc($name)), $teilnehmer{$search_name}; | ||
+ | } else { | ||
+ | printf "%s ist unbekannt!\n", $name; | ||
+ | } | ||
+ | </code> |