Perl_ca_user has asked for the wisdom of the Perl Monks concerning the following question:
Hey guys, I was trying to create in a 2-D array in my hash tag(well, it's kinda like a 3-D I guess).. When I tried to initialize it, I did something like:
and when I push stuff into the array, I did:my @array=(); $exonHash{$exonNumber}=\@array; #exonHash is the hashtag my @twoD_array0=(); my @twoD_array1=(); my @twoD_array2=(); my @twoD_array3=(); my @twoD_array4=(); $array[0]=\@twoD_array0; $array[1]=\@twoD_array1; $array[2]=\@twoD_array2; $array[3]=\@twoD_array3; $array[4]=\@twoD_array4;
It works in windows IDE, but out of no reason, after I upload it to linux, it gives error as Type of arg 1 to push must be array (not array slice) at average.pl line 86, near "$min)", which is saying the arrays are invalid. Do I have better ways to initialize arrays like this or did I make a mistake somewhere? Thank you very much.push(@{$exonHash{$exonNumber}}[1], $q1); push(@{$exonHash{$exonNumber}}[2], $med); push(@{$exonHash{$exonNumber}}[3], $q3); push(@{$exonHash{$exonNumber}}[4], $max);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: 2D array in Perl
by hdb (Monsignor) on Jun 20, 2013 at 19:57 UTC | |
Re: 2D array in Perl
by choroba (Cardinal) on Jun 20, 2013 at 19:37 UTC | |
by Perl_ca_user (Initiate) on Jun 20, 2013 at 19:47 UTC | |
by Happy-the-monk (Canon) on Jun 21, 2013 at 07:27 UTC | |
Re: 2D array in Perl
by toolic (Bishop) on Jun 20, 2013 at 19:39 UTC |
Back to
Seekers of Perl Wisdom