Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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

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 surveying the Monastery: (6)
As of 2016-09-28 06:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (520 votes). Check out past polls.