in reply to Multidimensional array
oshalla has addressed your coding error, but if you intend to further your Perl programming skills there are a couple of other things you did "wrong".
First, always use strictures (use strict; use warnings;).
Write Perl not C. In particular, Perl for loops are much safer and clearer than C for loops. Consider:
for ($k=0; $k<=$#Mdevices; $k++) { print $Mdevices[$k][0],"\n"; } for my $device (@Mdevices) { print $device->[0], "\n"; }
In fact a slightly more experienced Perl programmer would use a for statement modifier and the loop becomes:
print $_->[0], "\n" for @Mdevices;
In PerlMonks terms what you did wrong was to not show a runnable sample the demonstrates the problem. The code you provided doesn't show the problem that oshalla (using his elite esp skills) resolved for you. However if you had instead shown us:
for (1 ..5) { push (@Cdevices, "UnitId$_", $_); push (@Mdevices, \@Cdevices); } print $_->[0], "\n" for @Mdevices;
prints:
UnitId1 UnitId1 UnitId1 UnitId1 UnitId1
and told us what you expected to see instead we'd have known what the problem was straight off.
|
|---|