Acme-RPC
view release on metacpan or search on metacpan
lib/Acme/RPC.pm view on Meta::CPAN
# subroutine inside of a package, declared with sub foo { }, else *foo = sub { }, exported, or XS.
# save coderefs but only if they aren't XS (can't serialize those) and weren't exported from elsewhere.
my $ob = B::svref_2object(*{$package . $k}{CODE});
my $rootop = $ob->ROOT;
my $stashname = $$rootop ? $ob->STASH->NAME . '::' : '(none)';
if($$rootop and ($stashname eq $package or 'main::'.$stashname eq $package or $stashname eq 'main::' )) {
# when we eval something in code in main::, it comes up as being exported from main::. *sigh*
reg( $node->{$k.'()'}{chr(0)} = *{$package . $k}{CODE} );
}
} elsif( ref(*{$package.$k}{SCALAR}) ne 'GLOB' ) {
# found a scalar inside of the package... create an entry for the scalar itself and if it contains a ref, recurse, I guess
my $scalar = *{$package.$k}{SCALAR}; # this is a scalarref in the case of "our $var = 1" or other simple things
my $scalarcontains = $$scalar;
if(ref $scalarcontains) {
$node->{'$'.$k} = caller_cv(0)->($scalarcontains);
}
reg( $node->{'$'.$k}{chr(0)} = $scalar ); # have to do this after assigning in from the recursive call
}
}
# end for %{$package}, if %{$package}
} elsif(my $class = blessed($object)) {
( run in 1.269 second using v1.01-cache-2.11-cpan-702932259ff )