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,
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Safe / @ISA Problem
by simon.proctor (Vicar) on Mar 16, 2002 at 00:22 UTC | |
by rdw (Curate) on Mar 16, 2002 at 11:11 UTC | |
Re: Safe / @ISA Problem
by dragonchild (Archbishop) on Mar 18, 2002 at 14:07 UTC | |
by rdw (Curate) on Mar 19, 2002 at 17:35 UTC | |
by dragonchild (Archbishop) on Mar 19, 2002 at 17:39 UTC | |
by rdw (Curate) on Mar 19, 2002 at 20:44 UTC | |
Re: Safe / @ISA Problem - worked it out
by rdw (Curate) on Mar 19, 2002 at 20:49 UTC |
Back to
Seekers of Perl Wisdom