develooper Front page | perl.perl5.porters | Postings from November 1999

namespace problem on Safel

Yasushi Nakajima
November 16, 1999 01:28
namespace problem on Safel
Message ID:
Hello all

The namespace problem on Safe module was already discussed here. I don't
know the discussion since today, and made Safe::Hole module. It makes a
hole to the original root compartment in the Safe compartment

It is at:

My approach is:

1.An Safe::Hole object saves the original root stash.
2.The object wraps the subroutine or object which is shared or copied
into the Safe compartment. 
3.When the wrapped subroutine or object method is called, it is executed
in the original root compartment.

For example:

  use Safe;
  use Safe::Hole;
  $cpt = new Safe;
  $hole = new Safe::Hole;
  sub test { Test->test; }
  $Testobj = new Test;
  # $cpt->share('&test');  # alternate as next line
  $hole->wrap(\&test, $cpt, '&test');
  # ${$cpt->varglob('Testobj')} = $Testobj;  # alternate as next line
  $hole->wrap($Testobj, $cpt, '$Testobj');
  $cpt->reval('test; $Testobj->test;'); 
  print $@ if $@;
  package Test;
  sub new { bless {},shift(); }
  sub test { my $self = shift; $self->test2; }
  sub test2 { print "Test->test2 called\n"; }

Of course you must be careful to use Safe::Hole. But it is not more
danger than Safe::share(). The name 'Hole' may be too stimulative.

Sey Nakajima <>
Kyoto, Japan Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About