BEGIN { package Foo ; use strict ; use warnings ; sub new { my $class = shift ; my $this = { _var => 1, } ; bless $this, $class ; } sub task { # Long operation task Foo ~ 2 seconds my $this = shift ; print "Starting task Foo for $_[0]\n" ; sleep(2) ; ++$this->{ _var } ; print "Finished task Foo for $_[0]\n" ; } package Bar ; use strict ; use warnings ; sub new { my $class = shift ; # This is not very realistic code. # here it is just used as an # example to create an object that # contains a nested object my $this = { _var => 1, } ; $this->{ nestedFoo } = $_[0] ; bless $this, $class ; } sub task { # Long operation task Bar ~ 6 seconds my $this = shift ; print "Starting task Bar for $_[0]\n" ; sleep(6) ; ++$this->{ _var } ; print "Finished task Bar for $_[0]\n" ; } } #### package main ; use strict ; use warnings ; use MCE::Shared ; use Data::Dumper ; my $foo = new Foo ; my $bar = new Bar( $foo ) ; # my $barShared = MCE::Shared->share( { module => 'Bar' }, $foo ) ; # or # from examples: my $ob = MCE::Shared->share( $blessed_object ); my $barSh = MCE::Shared->share( Bar->new( $foo ) ) ; print Dumper( $barSh->export ) . "\n" ; $barSh->task( 'Bar' ) ; # OK $barSh->{ nestedFoo }->task( 'Foo' ) ; # Not a HASH reference # Program died here $barSh->export->{ nestedFoo }->task( 'Foo' ) ; # OK, but not shared? __END__ $VAR1 = bless( { '_var' => 1, 'nestedFoo' => bless( { '_var' => 1 }, 'Foo' ) }, 'Bar' ); Starting task Bar for Bar Not a HASH reference at testHobo3.pl line 60, <__ANONIO__> line 1. Finished task Bar for Bar