Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Caching or using values across multiple programs

by ELISHEVA (Prior)
on May 06, 2009 at 05:14 UTC ( #762166=note: print w/ replies, xml ) Need Help??


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


Comment on Re: Caching or using values across multiple programs
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (13)
As of 2015-07-29 16:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (265 votes), past polls