http://qs1969.pair.com?node_id=1149777


in reply to Re: Storing state of execution
in thread Storing state of execution

I would add that which you want depends a lot on the data you need to store.

If the data is simple and modestly sized, then JSON (or YAML) would probably be best.

If your data includes reference loops or binary data, or if the data structure is large (speed becomes an issue) then Storable would probably be best.

Dumper is more of a middle ground, if you need it to be coder-readable and it is a complex data structure, but you can absolutely trust the source of the data when you read it back. I'd only recommend it as debug output, since reading it back in involves running arbitrary perl code.

Replies are listed 'Best First'.
Re^3: Storing state of execution (speed)
by tye (Sage) on Dec 09, 2015 at 16:01 UTC
    or if the data structure is large (speed becomes an issue) then Storable would probably be best.

    That doesn't match my memory. A quick test showed JSON::XS taking just over 1/3 of the time of Storable (and producing almost exactly the same number of bytes of output).

    Using JSON has other advantages. And I consider forcing one to stick to simple data to be one of them.

    - tye