Re: 2 dimensions array



On 11-12-11 06:57 AM, kurtz le pirate wrote:

Hello,

I want to have a two dim array. I build it like this:

my @Cylinders;


/.*(<.*>),(<.*>).*/;
push @{$Cylinders[0]}, $1;
push @{$Cylinders[1]}, $2;


Seems to work but a get an array with '2' lines and 'n' columns
instead of 'n' lines with '2' columns'.


display array with 'print Dumper \@Cylinders;' confirm this.

where is my mistake ?



thank if you can help me.


Try:

push @Cylinders, [ $1, $2 ];

This will put the two captured variables in an anonymous array and push it onto @Cylinders.


--
Just my 0.00000002 million dollars worth,
Shawn

Programming is as much about organization and communication
as it is about coding.

Never give up your dreams. Give up your goals, plans,
strategy, tactics, and anything that's not working but never
give up your dreams.
.



Relevant Pages

  • Re: Queue question wih dyn mem alloc
    ... I wrote two functions to pusha character array onto an array and ... the push function seems to work well but i have ...   carrying character arrays. ... Did you mean to use curlen-1 here? ...
    (comp.lang.c)
  • Re: Queue question wih dyn mem alloc
    ... I wrote two functions to pusha character array onto an array and ... the push function seems to work well but i have ...   carrying character arrays. ... that's what i thought as well but if I make curlen-1 i always ...
    (comp.lang.c)
  • Re: Queue question wih dyn mem alloc
    ... I wrote two functions to pusha character array onto an array and ... the push function seems to work well but i have ...   carrying character arrays. ...  Every pointer that contains the address of reallocated ...
    (comp.lang.c)
  • Re: Interfacing the advanced data structures
    ... push @$group, $ID; ... and then for each group, the member ID's are labeled with the keyword "src", ... Just use a plain array ... grp 1: ...
    (comp.lang.perl.misc)
  • Re: Picking Element from Array one by one
    ... >> I am getting some values from loop and i store all that value in array ... >> using push function. ... no correllation. ... Please Rita, get it together woman. ...
    (comp.lang.perl.misc)