Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Class::Accessor and Storable

by Belgarion (Chaplain)
on Jan 20, 2005 at 21:55 UTC ( [id://423804]=perlquestion: print w/replies, xml ) Need Help??

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://423804]
Approved by virtualsue
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2025-07-18 03:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.