Array n dimensions 
Author Message
 Array n dimensions

Quote:

> How can I use (or simulate ?) array of n dimensions ?  How can
> manipulate them ?

You'll find some good information in the man pages, including perldsc,
perllol, and perlref. If you have perl questions after you've read the
docs and man pages, please post those questions here. Thanks!

--
Tom Phoenix           http://www.*-*-*.com/ ~rootbeer/

Randal Schwartz Case:   http://www.*-*-*.com/



Tue, 11 Jan 2000 03:00:00 GMT  
 Array n dimensions



Quote:
>How can I use (or simulate ?) array of n dimensions ?
>How can manipulate them ?

If you have a recent perl (perl 5.xxx) then you can simulate the use of
n-dimensional arrays by using arrays of references to arrays e.g.

  $array[2][3] = 'x';

stores makse $array[2] end up containing a reference to an array (probably
an anonymous array) whose fourth element (counting from 0) contains the
scalar 'x'.

The perllol (lol stands for lists of lists) manual page covers this in
more detail.

Hope this helps,

Mike

--

http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41



Tue, 11 Jan 2000 03:00:00 GMT  
 Array n dimensions

Quote:

> Hi,

> How can I use (or simulate ?) array of n dimensions ?
> How can manipulate them ?

If you have the Camel book, take a look at the description of the
special variable $;
This is used to mimic multi-dim arrays in Perl which are not
natively supported.

Cheers



Tue, 11 Jan 2000 03:00:00 GMT  
 Array n dimensions

Quote:

> If you have the Camel book, take a look at the description of the
> special variable $;
> This is used to mimic multi-dim arrays in Perl which are not
> natively supported.

Perhaps you are using the old Camel book, which should be retired. The new
Camel says on p. 133:

    This variable is for maintaining backward compatibility, so
    consider using "real" multi-dimensional arrays now.

Information on multi-dimensional arrays starts on p. 257. Hope this helps!

--
Tom Phoenix           http://www.teleport.com/~rootbeer/

Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



Tue, 11 Jan 2000 03:00:00 GMT  
 Array n dimensions


Quote:


> > How can I use (or simulate ?) array of n dimensions ?
> > How can manipulate them ?

> [...] This is used to mimic multi-dim arrays in Perl which are not
> natively supported.

He should have answered with "read the manual!"  At least that would have
been a *correct* answer...  You'll find out how to make a multi-dimensional
array (or "List of Lists") in the perllol man page.  Here's an example
from the first page of the manual:

| A list of lists, or an array of an array if you would, is just a regular

| Here's a declaration of the array:
|
|     # assign to our array a list of list references

|            [ "fred", "barney" ],
|            [ "george", "jane", "elroy" ],
|            [ "homer", "marge", "bart" ],
|     );
|
|     print $LoL[2][2];
|   bart

Only works with Perl 5.  (Do we even need to say that anymore?)

- Ken

--

                                         | not represent those of, nor are
Ford Motor Company, Powertrain           | endorsed by, Ford Motor Company.
Analytical Powertrain Methods Department |
Software Development Section             | "Is this some sort of trick
                                         |  question or what?" -- Calvin



Thu, 13 Jan 2000 03:00:00 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. How to convert multidimensional array to single dimension?

2. multi dimension array in Perl??

3. sorting multi-dimensioned arrays

4. fast sort for multi-dimension arrays

5. Multi dimensional array dimensions

6. shift multi-dimension array

7. shift multi-dimension array

8. Pushing onto multi-dimensioned arrays

9. determining size of multi-dimension arrays

10. Multi-dimension array creation

11. Sort 2 dimension array ?

12. multiple dimension arrays question

 

 
Powered by phpBB® Forum Software