Leser: 24
1
2
3
4
5
6
7
8
9
10
11
my @bes = (1,2,3);
my %waren = (
"plastik" => {nr => 1111,preis => 1000,verf => 'J',},
"metall" => {nr => 2222,preis => 2000,verf => 'N',},
"holz" => {nr => 3333,preis => 3000,verf => 'J',},
);
print "Bestellnummer: ".$bes[1]."\n";
print "Preis: ".$waren{plastik}{preis}."\n";
print "Preis: ".$waren{$bes[1]}{preis}."\n";
1 2 3 4 5 6 7 8 9 10 11 12 13 14
my @bes = (1111, 2222, 3333); my %waren = ( "plastik" => {nr => 1111,preis => 1000,verf => 'J',}, "metall" => {nr => 2222,preis => 2000,verf => 'N',}, "holz" => {nr => 3333,preis => 3000,verf => 'J',}, ); for my $k (keys %waren) { my $nr = $waren{$k}{nr}; $waren{$nr} = $waren{$k}; } print "Bestellnummer: ".$bes[1]."\n"; print "Preis: ".$waren{metall}{preis}."\n"; print "Preis: ".$waren{$bes[1]}{preis}."\n";