in reply to Multi dimentions to a single dimentional array

You're not going blind nor insane but your mission is half-way through, cheers, your multi-dimensional array has been assigned and built successfully, for each element in the dimension referenced you need to appropriately dereference it to be able to access it...

When you loop through the first dimension you'd be looping through anonymous arrays as elements of that dimension hence $f would refer to an anonymous array, dereferencing that anonymous array using the infix arrow operator would enable you access its elements in turn too..

use strict; use warnings; my @ary = ( #First Dimension ['Jan', 10, 20], #second Dimension ['Feb', 15, 25], ['Mar', 30, 33] ); foreach my $f (@ary) { print "==> $f->[0]\n"; #infix Arrow Operator dereferencing.. #print "==> @{$f}[0]\n"; #another way of dereferencing too..(T +ry It) }

Update: You can still achieve the same through indexing in a for loop, here are some of the different ways this is possible:

for (my $i=0;$i<=$#ary; $i++){ print "==>$ary[$i][0]\n"; # print "==>@{$ary[$i]}[0]\n"; # print "==>$ary[$i]->[0]\n"; }

It's worthwhile investing time in reading Perl data structure cookbook, manipulating arrays of arrays in Perl, References Tutorial and the Monastery's very own tutorials on the subject at References...


Excellence is an Endeavor of Persistence. Chance Favors a Prepared Mind.