Have you looked at Storable? It may help you.
It can store objects to the filesystem or to memory, then
retrieve them, transforming them back into objects.
So perhaps you could freeze the object to a scalar, store
it in a blob in your database, pull it back out, thaw it,
then use it again? I don't know--I've only tested Storable
using the filesystem, but it seems logical that you could
do the same thing w/ a database.
You might be able to do something like this (untested):
use Storable qw/freeze thaw/;
use Foo; # replace this with your module name
my $object = new Foo;
my $dbh = DBI->connect('bar', 'foo', 'foo', 'Oracle')
or die "Can't connect: ", DBI->errstr;
# store it
my $sth = $dbh->prepare(<<SQL) or die "Can't prepare: ", $dbh->errstr;
insert into objects (id, content)
values (?, ?)
$sth->execute("foo", freeze $object)
or die "Can't execute: ", $dbh->errstr;
# now get it back
my $retrieve = $dbh->prepare(<<SQL) or die "Can't prepare: ", $dbh->er
where id = ?
my $content = $retrieve->fetchrow;
my $unthawed = thaw $content;
...and now use $unthawed just as you would your original
Does this sound like what you want?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||