I've done pretty much exactly what you've asked for (ie persistance with a DB) here.

More specifically, the code is an MP3 server that goes and gets a playlist from a DB (all a playlist is is a bunch of fully qualified mp3's, one per line in a text file).

My playlists are generated by getting a list of mp3's storing them in an array, freezing (using Storable) the array, unpacking it to hex to remove any naughty characters, then storing in a RDMBS using DBI.  BINDVAR=> unpack("H*",freeze(\@{$params{PLAYLIST}}))

My server then does the reverse. It goes and gets the playlist, packs it pack up, thaws it, and the result is the same array I put in there when the playlist was generated.

sub { .. .. my @ary = $sth->fetchrow_array; .. .. my $retval = thaw(pack("H*", @ary) ); return @{$retval} }

I'm currently working on a module that will do specifically what you are after (persistant storage in a db) to hone my OOP skills, so if you have any suggestions, /msg me, I'm open to ideas.


In reply to Re: Need a module for persistence of dynamic objects by Ryszard
in thread Need a module for persistence of dynamic objects by rinceWind

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.