in reply to Re^3: How to save and reload my hash
in thread How to save and reload my hash

I appreciate the feedback. I did notice something in all the examples I've been able to find regarding Storable and JSON. It has to do with the load from file back to the hash itself. Unless I'm missing something, and that's very possible, there seems to be a missing component of the hash reconstruction from the anonymous hash example %{} illustrated in responding comments. PERL seems to be handling the illusion of the reconstructed hash, until you try and use it in a foreach/keys loop. The assignment becomes a hashref which doesn't seem to fully reconstitute the hash from the file, because I could not get it to work with the foreach/keys loop. It wasn't until I learned about %$ to correct that. Do you see any issues with %$ ? The PERLDOC for Storables warned about the retrieve, would cause some sort of serialization pitfall, thus, causing the foreach/keys not to work. Until %$. The code examples used in the response, served my purpose for a daily PERL script I run at least 20 times a day, and may offer some relief to others trying to reconstitute the hash from a file, so it works as it did before the store.

Replies are listed 'Best First'.
Re^5: How to save and reload my hash
by Your Mother (Archbishop) on Sep 25, 2014 at 15:50 UTC

    If Storable is doing it for you, don’t worry. It’s only something to worry about in certain circumstances or if you like to be able to eye-ball the data. Storable and JSON both serialize and marshal (deserialize) references. It’s fully reconstituted, it just has to be accessed with dereferencing semantics (%$hash or $hash->{key}); you might want to look at perlref. Sounds like you have it working now though, so ++