Length of Array of Array of Array

T

Tom

How to find the length of an "Array of Array of Array"

I get syntax error when i say $#fx[0][0][0]
 
M

Matija Papec

X-Ftn-To: Tom

How to find the length of an "Array of Array of Array"

I get syntax error when i say $#fx[0][0][0]

This should give you the latest index from third level array,
$#{ $fx[0][0] }
 
T

Tad McClellan

Tom said:
How to find the length of an "Array of Array of Array"

I get syntax error when i say $#fx[0][0][0]


Well first off, the $#array syntax does NOT give you the length
of the array, it gives you the last index in the array.

The @array syntax in a scalar context gives you the length of the array.


To find the length of your multi-dim array, simply apply "Use Rule 1" from:

perldoc perlreftut


I usually do it in 3 steps:

my $length = @array; # pretend it is a regular old array

my $length = @{ }; # replace the _name_ of the array with a block

my $length = @{ $fx[0][0][0] }; # fill in the block with code that
# returns a reference to the
# right kind of thingy
 
S

salsablr

Thanks for the Info, I figured out and its working

$# {$g_Ao_TEList[$index]{$teIt}[0][0]} yields the last index of the
array.

Well, I'm yet to figure out what is causing the problem.
My data structure is a little complex (atleast complex for me)

$# {$g_Ao_TEList[$index]{$teIt}[0][0]}
<=== This doesn't works; infact i tried to store the count in
$lines which results nothing.

I have an "Array(1)" which references to "Array of Hashes" and the
value of each of the keys in the array references to an "Array of Array
of Array"

Now 'm trying to get the last index of the Array from "Array of Array
of Array".... Any pointers..


Tad said:
Tom said:
How to find the length of an "Array of Array of Array"

I get syntax error when i say $#fx[0][0][0]


Well first off, the $#array syntax does NOT give you the length
of the array, it gives you the last index in the array.

The @array syntax in a scalar context gives you the length of the array.


To find the length of your multi-dim array, simply apply "Use Rule
1"
from:

perldoc perlreftut


I usually do it in 3 steps:

my $length = @array; # pretend it is a regular old array

my $length = @{ }; # replace the _name_ of the array with a block

my $length = @{ $fx[0][0][0] }; # fill in the block with code that
# returns a reference to the
# right kind of thingy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top