in reply to Re: Array of Hashes in subroutines.
in thread Array of Hashes in subroutines.
Not that it'll make a difference here, but you should always enable warnings in your code ...
Actually, it could have made a big difference, at least in the OPed code, had jlnh been aware of the significance of warnings.
In that code, the statement
my @ref01 = shift;
creates and initializes an array that has (and can have) only one element upon initialization. The statement
print "$i: ${$ref01[0]}{$i} ${$ref01[1]}{$i} ${$ref01[2]}{$i}\n";
then tries to access non-existent elements at indices 1 and 2 ($ref01[1] and $ref01[2]) of that array, yielding undefined values to print. This would have produced a slew of warnings, had they been enabled, that might have directed jlnh to the essential problem (of many).
Also: See the Data Structures Cookbook perldsc.
|
|---|