I am trying to send OIO objects through IPC between processes on two different hosts. I have not been able to do so unless the receiving process has a proper 'use' statement for the package of the object being received. This prevents me from being able to send and receive "arbitrary" objects, i.e objects of a class not known at compile time by the receiving process. I have included a simple example below that does not rely on IPC but exhibits the same behavior (for what I believe are the same reasons).
Put in Foo.pm
package Foo;{
use strict;
use warnings;
use Object::InsideOut qw(Storable);
my @bar :Field :Arg(Name=>'bar', Mandatory=>1);
}
1;
Put in unload.pl
use strict;
use warnings;
use lib '.';
use Foo;
my $file = 'object.stor';
my $object = Foo->new( bar => 10 );
$object->store($file);
Put in load.pl
use strict;
use warnings;
use Storable qw(retrieve);
my $file = 'object.stor';
my $object = retrieve($file);
Run unload.pl and then load.pl. You should see this error:
OIO::Args error: Unknown field name for class 'Foo': bar
Package: Storable
File: blib/lib/Storable.pm (autosplit into blib/lib/auto/Storable/_retrieve.al)
Line: 331
Does this make sense? Is there any way to accomplish this?
Jerome