in reply to Multi dimensional arrays
Now what I am doing is iterating over the contents of the array and testing each element using the builtin 'ref'. Now if the array element is an arrayref, I iterate over that and print the contents. This prints:use strict; use warnings; my @array = ("w", "h", [1, 2, "c"]); foreach (@array) { if(ref($_) eq 'ARRAY') { foreach (@{$_}) { print $_,"\t"; } print "\n"; } else { print $_,"\n"; } }
To print the contents of the array ref - I first have to dereference it by using @{}. This is the way I do it though there are most likely other methods.w h 1 2 c
|
|---|