I'm working with a database interface (DBI) that returns information
by returning a reference ($Z) to an array of arrays.
When I run the program in the debugger, and ask for $Z, I get:
0 ARRAY(0x20d5e8)
0 ARRAY(0x41acfc)
0 26412
1 'ORLANDO'
2 'WV'
3 '-80.5145'
4 38.9458
5 'US'
6 10577
1 ARRAY(0x41adbc)
0 32801
1 'ORLANDO'
2 'FL'
3 '-81.3733'
4 28.5452
5 'US'
6 13818
2 ARRAY(0x41ae28)
0 32802
1 'ORLANDO'
2 'FL'
3 '-81.3439'
4 28.519
5 'US'
6 13819
3 ARRAY(0x41d590)
0 32803
1 'ORLANDO'
2 'FL'
3 '-81.3366'
4 28.5565
5 'US'
6 13820
etc.
When I write $Z->[2][3] I get the expected -81.3439.
Now the questions:
If I want to iterate over each of these elements, to print out a line
at a time, how do I do it?
Of course, I could do something like this:
for (i=0;i<ARRAYSIZE;i++) {
for (j=0;j<SIZEOFINNERARRAY;j++) {
print "$Z[i][j]," ";
}
print "\n";
}
But this isn't very "Perl-like" and it leaves the question of how do
I know the ARRAYSIZE and SIZEOFINNERARRAY (which is known in this
case, but as a general case, may not be known)?
I'd like to use something like a nested "foreach" loop... and the
code should evaluate the size of each innermost array - so for
example, if an inner array had size 4 instead of 7, it would be
detected (so I don't iterate over non-existent values).
Thanks.
and Merry Christmas!
Kurt
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]