Insert Array of Array perl -


i have array of array

@data = [["hi", "hello"],["apple", "orange"]]; 

and need insert new array

@a = ["a", "b"];

i array @data looks this

@data = [["hi", "hello"],["apple", "orange"], ["a", "b"]]; 

how can that?

when type

[ "foo", "bar", "base" ] 

it's not simple array, reference array:

my $ref = [ "foo", "bar", "base" ]; print $ref; 

displays example:

array(0x1d79cb8) 

a simple array @array assigned simple list:

my @array = ( "foo", "bar", "base" ) 

still using reference:

use data::dumper;  # using $array_ref store reference. # there's no reason use @array store # memory address string... $array_ref = [["hi", "hello"],["apple", "orange"]];  # pushing in dereferenced array ref push @$array_ref,  ["a", "b"];  # let's doctor take in body print dumper $array_ref; 

output:

$var1 = [           [             'hi',             'hello'           ],           [             'apple',             'orange'           ],           [             'a',             'b'           ]         ]; 

seems expect, no?


see perldoc perlreftut


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -