G'day JockoHelios,
From your original post and your replies to frozenwithjoy and LanX, you appear to be experiencing a fair amount of confusion. Perhaps this short annotated script might inject some clarity:
$ perl -Mstrict -Mwarnings -le ' use Data::Dumper; # Declare an empty array (Note: no "splice" required) my @records; # Initialise the array with 2 elements # Each element must be a scalar # If an element is an array of values, you need an arrayref @records = ( [ "A", 1, 2, 3 ], [ "B", 4, 5, 6 ] ); print "\$records[1][2]: ", $records[1][2]; # Push another array of values (as an arrayref) push @records, [ "C", 7, 8, 9 ]; print "\$records[2][2]: ", $records[2][2]; # "join" creates a string (strings are scalar values) push @records, join ",", "D", 10, 11, 12; print "\$records[3]: ", $records[3]; # Add a hash (as a hashref - which is also a scalar value) push @records, { E => 13, F => 14, G => 15 }; print "\$records[4]{G}: ", $records[4]{G}; # The entire data structure: print Dumper \@records; ' $records[1][2]: 5 $records[2][2]: 8 $records[3]: D,10,11,12 $records[4]{G}: 15 $VAR1 = [ [ 'A', 1, 2, 3 ], [ 'B', 4, 5, 6 ], [ 'C', 7, 8, 9 ], 'D,10,11,12', { 'G' => 15, 'F' => 14, 'E' => 13 } ];
See also: splice, join, perldsc - Perl Data Structures Cookbook.
-- Ken
In reply to Re: element of an array of arrays
by kcott
in thread element of an array of arrays
by JockoHelios
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |