R
russell.brooks
Hi,
I've created a hash of an array. There are a varying number of
elements in the arrays. I need to count the number of elements, and
although I have read through the documentation, I have been unable to
find a clean way of doing this.
For example,
$table{28}[0] = 541;
$table{36}[0] = 1024;
$table{36}[1] = 2048;
$table{36}[2] = 4096;
$table{36}[3] = 8192;
$table{51}[0] = 77;
What I'm trying to obtain is a count of values for each array in the
hash. For example, the above example has 4 values associated with
array 36.
scalar keys %table gives 3, which isn't what I need.
scalar keys $tables{28} is illegal since the arguments for keys must
be a hash, not a hash element.
Is iterating through the hash the best option?
Thanks,
Russ
I've created a hash of an array. There are a varying number of
elements in the arrays. I need to count the number of elements, and
although I have read through the documentation, I have been unable to
find a clean way of doing this.
For example,
$table{28}[0] = 541;
$table{36}[0] = 1024;
$table{36}[1] = 2048;
$table{36}[2] = 4096;
$table{36}[3] = 8192;
$table{51}[0] = 77;
What I'm trying to obtain is a count of values for each array in the
hash. For example, the above example has 4 values associated with
array 36.
scalar keys %table gives 3, which isn't what I need.
scalar keys $tables{28} is illegal since the arguments for keys must
be a hash, not a hash element.
Is iterating through the hash the best option?
Thanks,
Russ