http://www.perlmonks.org?node_id=3711

chromatic has asked for the wisdom of the Perl Monks concerning the following question:

I'm curious as to the best (or possible) way to store an existing Perl object in a database. I'd use the DBI module.

What I have are a handful of classes (raw objects with default data) in modules -- things are already defined there. I would be creating new instances of those objects with different data. I'd like to store those in a database.

One option would be to gather up all of the data in the instance objects, db-ify it, and use the primary key of that row in the db to pull the data out and put it into a newly made object. That's not a bad solution.

Is there any way I can store new classes and objects in a database without having to use eval all the time or write the objects to the normal filesystem and then require them?