use strict; use warnings; use Data::Dump qw(dump dd); my @p=(); my @l=([9,7],[3,4]); # array of 2 coodinates push @p,['FOO',@l]; # array with the string FOO with those coordinates push @p,['BAR',[8,0]];# BAR and one coordinate dump \@p; #[["FOO", [9, 7], [3, 4]], ["BAR", [8, 0]]] #note outermost brackets are artifact of way we called dump as #a reference to an array # throw away FOO and BAR # my @new =map{my @elements = @$_; #This gets "FOO", [9, 7], [3, 4] shift @elements; #throw away FOO [@elements]}@p; #repackage array inside of brackets #back to being a reference to array dump \@new ; # [[[9, 7], [3, 4]], [[8, 0]]] # often it is convienent to make all elements to the structure the same # here packaging the string foo as a single element of an array ref is fine. my @x; push @x,[['FOO'],@l]; # array with the string FOO with those coordinates push @x,[['BAR'],[8,0]];# BAR and one coordinate my @flat = map{@$_}map{@$_}@x; print "@flat\n"; # FOO 9 7 3 4 BAR 8 0