Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://762166]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2018-02-21 02:10 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (274 votes). Check out past polls.