http://www.perlmonks.org?node_id=152108

rdw has asked for the wisdom of the Perl Monks concerning the following question:

I've been playing around with Safe, but I've hit a problem with @ISA / inheritance, and I can't seem to work round it. I managed to strip everything right back to a very small example which shows the problem.

#! /usr/bin/perl -w use strict; use Safe; my $CODE = << 'END'; package A; sub new { my($class) = @_; bless { }, $class; } package B; our @ISA = qw(A); END # If I uncomment this line, everything works. # eval $CODE; my $safe = Safe->new(); $safe->reval($CODE); warn "code - $@" if $@; $safe->reval("B->new();"); warn "new - $@" if $@;

When I run this, I get "Can't locate package A for @B::ISA" (twice). If I uncomment the eval, then the problem goes away - but of course in the real app, I don't want to eval the untrusted code outside of Safe (so just suggesting that I uncomment it, isn't going to help me much :-)

Can someone explain to me what's going on? Any idea how I might get round this problem?

Have fun,

rdw