in reply to Caching or using values across multiple programs
Storable does a binary dump. That could be an efficiency bonus or a debugging nightmare. If you want something you can inspect and read, consider either JSON or YAML.
Personally, I would recommend YAML. I've worked with both and YAML is a lot more flexible than JSON, especially when it comes to hashes. For example,
- JSON does not handle circular references safely, YAML does.
- you can control the order of hash keys much more easiliy in YAML than in JSON.
- JSON dumps blessed objects as undef or throws an exception unless the object's class has a TO_JSON method. YAML defines a default mechanism for dumping objects. If your hash key values are object references, this might be an issue.
- JSON has no syntax for encoding the class into which an object is blessed. So even if you write a TO_JSON method for the class, you will have to get creative if you want to store the class into which the hash should be blessed.
- JSON is not friendly to code ref dumps. YAML is. If your hash key values are code references, this might be an issue.
Despite a subset of nearly alike syntax, there are some small but very differences in YAML and JSON syntax. For example, YAML strings need to end with a newline. JSON barfs when they do. If you only have time to learn one, YAML will cover more use cases and take you farther.
Best, beth
In Section
Seekers of Perl Wisdom