[PLUG] Perl 3D array - printing all values
Matt Alexander
m at pdxlug.org
Wed Oct 22 13:50:03 UTC 2003
Matt Alexander said:
> Paul Heinlein said:
>> On Wed, 22 Oct 2003, Matt Alexander wrote:
>>
>>> I have a 3 dimensional array in Perl...
>>>
>>> $myarray[$val1][$val2][$val3]
>>>
>>> I would like to print every value in the array.
>>
>> foreach my $x ( @myarray ) {
>> foreach my $y ( @{$x} ) {
>> foreach my $z ( @{$y} ) {
>> print $myarray[$x][$y][$z], "\n";
>> }
>> }
>> }
>
> Eeeeeeeeenteresting... Thanks Paul!
Even more interesting is that I ran a test with 3 elements and it brought
my computer to a screaching halt with the following message:
Use of reference "ARRAY(0x804c970)" as array index at testing.pl line 10.
Line 10 is the print statement...
More information about the PLUG
mailing list