in reply to Perl sandbox

You might could use B::Generate to muck about with the OP tree, but you'd be getting into very deep wizardry (not that you're in the kiddie pool with Safe to begin with :).

Simpler might be to write a replacement open that disallows absolute paths and paths with `..' in them and only allow that sub to be called from the compartment.