1
2
3
my @vorname = ('Jule', 'Claudia', 'Susi');
my @haarfarbe = ('rot', 'blond', 'schwarz');
my @figur = ('schlank', 'zierlich', 'mollig');
1
2
3
4
5
@multi_array = (
["Jule", "rot", "schlank"],
["Claudia", "blond", "zierlich"],
["Susi", "schwarz", "mollig"],
);
1
2
3
4
5
my $i = 0;
foreach (@vorname) {
$multi_array[$i] = [$vorname[$i], $haarfarbe[$i], $figur[$i]];
$i++;
}
1 2 3
foreach my $i (0 .. @vorname - 1) { $multi_array[$i] = [ $vorname[$i], $haarfarbe[$i], $figur[$i] ]; }
push(@multi_array,[shift(@vorname), shift(@haarfarbe), shift(@figur)]) while(@vornmane);
$array[$i][0] # 0 ist der Vorname
$array[$i]{vorname}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
my @vorname = ('Jule', 'Claudia', 'Susi'); my @haarfarbe = ('rot', 'blond', 'schwarz'); my @figur = ('schlank', 'zierlich', 'mollig'); my %merged = map{ $vorname[$_] => { hair => $haarfarbe[$_], body => $figur[$_] } }0 .. scalar @vorname - 1; print Dumper \%merged; # ausgabe $VAR1 = { 'Jule' => { 'body' => 'schlank', 'hair' => 'rot' }, 'Claudia' => { 'body' => 'zierlich', 'hair' => 'blond' }, 'Susi' => { 'body' => 'mollig', 'hair' => 'schwarz' } };
my @multi = (\@vorname, \@haarfarbe, \@figur);
1
2
3
4
5
6
7
8
9
my @array = ('Jule', 'Claudia', 'Susi');
my @array1 = ('rot', 'blond', 'schwarz');
my @array2 = ('schlank', 'zierlich', 'mollig');
my $array_reference = \@array;
my $array1_reference = \@array1;
my $array2_reference = \@array2;
my @profiles_sql = ($array_reference, $array1_reference, $array2_reference);
1
2
3
4
5
@profiles_sql = (
["Jule", "Claudia", "Susi"],
["rot", "blond", "schwarz"],
["schlank", "zierlich", "mollig"],
);
QuoteIst Dein Codebeispiel nicht genu das selbe (nur in Kurzform) oder irre ich?
my @merged = map{[$vorname[$_], $haarfarbe[$_], $figur[$_]]} 0 .. scalar @vorname - 1;
1 2 3 4 5 6 7 8 9 10 11 12 13 14
use 5.012; use List::MoreUtils qw(part zip); my @vorname = ('Jule', 'Claudia', 'Susi'); my @haarfarbe = ('rot', 'blond', 'schwarz'); my @figur = ('schlank', 'zierlich', 'mollig'); my @multi_array = do { my $i = 0; part { $i++ / 3 } zip @vorname, @haarfarbe, @figur; }; use Data::Dumper; print Dumper \@multi_array;