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

Are there any known problems with using Storable with a Class::Accessor derived module? I'm trying to nfreeze a module derived from Class::Accessor and send it across a Unix socket to be thawed by another application. The nfreeze method seems to work fine, and the thaw succeeds without an error; however, when I try to access a method defined in the class's mk_accessors method I receive an error stating that the thawed object doesn't have a method by that name.

Is what I'm trying to do impossible, or should I be looking in a different direction?

Thank you for any help you can provide.

Replies are listed 'Best First'.
Re: Class::Accessor and Storable
by Joost (Canon) on Jan 20, 2005 at 23:29 UTC
    This may be a stupid question, but does the other application actually load ("use") the class (module) the object is blessed in before you thaw the object? I don't think storable does this automatically. Also, the subclass should probably explicitly use Class::Accessor or use base 'Class::Accessor', if it doesn't already does so.

      Thanks Joost++! I added the use ModuleName to the client code and it works correctly now.

Re: Class::Accessor and Storable
by edoc (Chaplain) on Jan 21, 2005 at 02:06 UTC

    not sure if this is related, but I did have issues once which, after many hours of frustration, I discovered stemmed from my use of Storable which exports the methods store & retrieve. My module was a subclass of another which used the method store somewhere.. I wasn't even aware of it.. Anyway Storable was overriding the store method and causing some really weird errors. The solution of course was quite simple..

    use Storable();

    as opposed to

    use Storable;

    cheers,

    J