The stupid question is the question not asked | |
PerlMonks |
Re^3: Generate Array of Hashes WITHOUT Referencesby LanX (Saint) |
on Sep 09, 2014 at 12:01 UTC ( [id://1099982]=note: print w/replies, xml ) | Need Help?? |
> I fail to see how explanations that you can only store scalars .. 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 Section
Seekers of Perl Wisdom
|
|