Keep It Simple, Stupid | |
PerlMonks |
Re: Converting Hashes to Objectsby tobyink (Canon) |
on May 18, 2020 at 07:55 UTC ( [id://11116886]=note: print w/replies, xml ) | Need Help?? |
I wrote Object::Adhoc recently which is pretty similar.
Main differences are that mine doesn't work recursively, and mine also generates has_foo methods. If you need nested objects, my solution would be to just be explicit:
As far as adding things like constructors and methods, I consider that beyond the scope of Object::Adhoc; use a proper class builder for that. Object::Adhoc is just for those cases where you want a sub to return something dict/struct-like. object { ... } is conceptually a quote-like operator.
In Section
Meditations
|
|