Please note that you're loading the object from a file with the name of the dereferenced $sref_file, but you're storing it in './object.dat,' even though you pass $sref_file to that as well- that's simple to fix :)

I'm also not a big fan of Exception; rather, I like to use Error. I just love being able to throw different types of errors with about two seconds of code as well as the utter extensibility that Error provides:
package SomeError; @ISA = qw(Error::Simple);
Then you can throw an error of type 'SomeError', and you can create even more complicated hierarchies of errors so easily with Error.pm (just have another, more specific subset of SomeError inherit from it.) It's a perfect use of Universal::isa().

Error's errors also propogate down, so if you throw an exception on an upper sub, you can catch it later. This allows you to not have to return the error if there is one, and instead follow the standard rule of 0 or undefined on failure, and true of success (you could still do this, but Error.pm makes it really intuitive to me.) Furthermore, you wouldn't have to comment out the thrown errors, because if they weren't asking to be caught somewhere, they'd never really be used (this is my knowledge of Error.pm- just use record(), and never catch the error. However, this is possible using either error module again, probably)...

Also, afaik-  \%{ $self } == $self, so  Storable::store ( \%{ $self }, './object.dat' ); could be  Storable::store ($self,'./object.dat' );.

Instead of storable, I'm also becomming a fan of YAML, if you haven't tried it- try it! It's pretty cool, and you can actually read the files it generates (I'm not sure if it'd be good for saving a reference to an object, because I've never tried that using it, but I expect it would do fine...)

In reply to Re: General Class Creation Using Persistent Object, Method Privacy Enforcement and Exceptions by Revelation
in thread General Class Creation Using Persistent Object, Method Privacy Enforcement and Exceptions by DeadPoet

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.