http://www.perlmonks.org?node_id=939524

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

I am writing an IPC shell module to provide interprocess runtime hooks. I am using freeze and thaw from the Storable module to pass Command objects over a socket on localhost. Before freezing the object, these methods are available:

RETURN_IN_ORDER GetOptions DESTROY run AUTOLOAD ISA BEGIN PERMUTE isa new _init REQUIRE_ORDER

However, after thawing, only AUTOLOAD and DESTROY are available.

Here is the code for sending the frozen object over the socket (I've ensured send is working properly)

$self->{channel}->send(freeze(\$command));

And for unthawing (again, I know receive_nb to work properly)

my $command = thaw($self->{channel}->receive_nb());

Replies are listed 'Best First'.
Re: Storable freeze/thaw losing object methods
by ikegami (Patriarch) on Nov 22, 2011 at 20:14 UTC
    Objects don't have methods; classes do. Did you load the module providing the class?
      You were correct. I had neglected to require the module once more in the separate process. Thank you!
      Yes, I did provide the module.
Re: Sorable freeze/thaw losing object methods
by BrowserUk (Patriarch) on Nov 22, 2011 at 19:47 UTC

    Have you checked the size of what you receive is the same as the size of what you send?


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      I have not, but my assumption was if the serialized object was getting truncated in the process, it would no longer be unserializable (dangerous assumption since I haven't looked into how freeze/thaw work). How can I check the size of an object?
        How can I check the size of an object?

        Check the size of the transmission:

        my $toSend = freeze(\$command ); print length $toSend; $self->{channel}->send( $toSend ); ... my $received = $self->{channel}->receive_nb(); print length $received; my $command = thaw( $received );

        But ikegami's probably hit the nail on the head. Have you used the class at the receiver?


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.