Hi Leute!
Ich hab folgenden Hash angelegt:
$food_color = (
Raspberry => "blue",
Apple => "green",
Banana => "yellow",
Cherry => "red"
);
und diesen Hash möchte ich mit dieser foreach-Schleife auslesen:
# food color per the introduction
foreach $name ("Banana", "Martini")
{
if(exists($food_color{$name}))
{
# it exists
print "$name is a food. \n";
}
else
{
# it doesn't
print "$name is a drink.\n";
}
}
Nun ist es aber so, dass mir die foreach-Schleife beim print nix ausgibt. Was ist beim Hash falsch?
Last edited: 2014-05-05 10:37:40 +0200 (CEST)