in reply to How to use Safe to compile anonymous subs
#!/usr/bin/perl use Safe; use IO::File; my $code =<<'END'; my $a = ''; my $f = IO::File->new('/etc/passwd'); while (my $l = $f->getline) { $a .= $l } return $a; END my $compartment = Safe->new; $safe = sub { $compartment->reval($code) || die $@}; print $safe->();
This way the reval complains with Can't locate object method "new" via package "IO::File", which seems to me what you want (and a use is caught).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to use Safe to compile anonymous subs
by lstein (Novice) on Jul 30, 2008 at 19:27 UTC | |
by moritz (Cardinal) on Jul 30, 2008 at 19:50 UTC | |
by Perlbotics (Archbishop) on Jul 30, 2008 at 20:04 UTC | |
by rir (Vicar) on Jul 30, 2008 at 20:02 UTC |