Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: Generate Array of Hashes WITHOUT References

by LanX (Saint)
on Sep 09, 2014 at 12:01 UTC ( [id://1099982]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Generate Array of Hashes WITHOUT References
in thread Generate Array of Hashes WITHOUT References

> 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 ☆☆☆☆ :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1099982]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-20 15:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found