Thread zahl in variabler? (6 answers)
Opened by chmod777 at 2012-09-26 19:35

hlubenow
 2012-09-26 22:28
#162062 #162062
User since
2009-02-22
877 Artikel
BenutzerIn
[default_avatar]
Oder so mit Standardmitteln:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
my $vergleich = 4;
my @a = (3,4,14,43);
my $isin = 0;
foreach my $elem (@a) {
    if ($vergleich == $elem) {
        $isin = 1;
        last;
    }
}
if ($isin) {
    ... mache planA ...
} else {
    ... mache planB ...
}

Da man sowas öfter braucht, hab' ich das für mich in einer Funktion "isin()" gekapselt.

View full thread zahl in variabler?