1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
my @all; my %m1; $m1{'eins'} = 1; $m1{'zwei'} = 2; my %m2; $m2{'eins'} = 11; $m2{'zwei'} = 12; @all[0] = %m1; @all[1] = %m2; print $m1{'eins'} . "\n"; print $m1{'zwei'} . "\n"; my %test = @all[0]; print %test; print "\n"; print %test . "\n"; print $test{'eins'} . "\n";
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#!/usr/bin/perl use warnings; use strict; my @all; my %m1; $m1{'eins'} = 1; $m1{'zwei'} = 2; my %m2; $m2{'eins'} = 11; $m2{'zwei'} = 12; $all[0] = \%m1; $all[1] = \%m2; print $m1{'eins'} . "\n"; print $m1{'zwei'} . "\n"; my %test = %{$all[0]}; my $i; foreach $i (keys(%test)) { print "$i \t $test{$i}\n"; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14
use v5.12; use warnings; my %m1 = ('eins' => 1, 'zwei' => 2 ); my %m2 = ('eins' => 11, 'zwei' => 12 ); my @all = (\%m1, \%m2); say $m1{'eins'}; say $m1{'zwei'}; my %test = %{ $all[0] }; say "%test"; say $test{'eins'};
1 2 3 4 5 6 7 8 9 10
use v5.12; use warnings; my @all = ({'eins' => 1, 'zwei' => 2 }, {'eins' => 11, 'zwei' => 12 }); my $test = $all[0]; say "%$test"; say $test->{'eins'};
Guest BlubHi,
bin recht neu in perl und habe ein Problem mit den Datentypen.
Genauer gesagt mit Arrays, die als Elemente Maps haben.