I read the question as:
"How can I avoid the dereferencing in $rec->{$key}=$value " and not "How can I store non-ref hashes in arrays."
He tried $rec{$key}=$value but failed b/c he used %rec now.
> ...and that still won't work, because the code ultimately does a push @AoH, $rec;
true, but this was already demonstrated by Hameed but w/o explanation ... an explanation I added, without testing the code.
Telling the OP (like most did here) that he can ultimately only store refs doesn't answer his question how to avoid dereferencing BEFORE storing.
Of course most of his errors would have easily be visible if he used strict and warnings .
But - alas - he mentioned that he took the code from the perldocs which (like I checked) don't use these pragmas either. :-(
Finally I posted from mobile, it's hard to give working code from Android.
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
In reply to Re^3: Generate Array of Hashes WITHOUT References
by LanX
in thread Generate Array of Hashes WITHOUT References
by tel2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |