ariels has asked for the wisdom of the Perl Monks concerning the following question:
Using the :default opset works. Which op do I need to add to :base_code to allow prototype lookup to work?
The enclosed code demonstrates:
#!/usr/local/bin/perl -w use strict; use Safe; # Stuff from here will be shared into the Safe compartment package Shared; { my $n; sub foo() { ++$n }; } package main; my $cpt = new Safe; $cpt->permit_only(':base_core'); $cpt->share_from( Shared => [qw( &foo )] ); print "foo returns ", Shared::foo, "\n" for (1..3); sub safe_eval { my $q = shift; my $res = $cpt->reval($q); if ($@) { "ERROR: $@\n"; } else { "$res\n"; } } print "reval(foo) returns ", safe_eval('foo') for (1..3); print "reval(foo()) returns ", safe_eval('foo()') for (1..3);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Prototype weirdness in Safe
by ariels (Curate) on Jul 22, 2001 at 14:12 UTC |