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

I have used Safe->reval to create a new function:
my $method = reval("return sub { $body };");
Within the $body (read from an XML definition) open3 and gensym are used to execute a command. When executing $method:
&{$method}(...)
I get a warning and an exception:
Use of uninitialized value in subroutine entry at (eval 66) line 13. Undefined subroutine & called at (eval 66) line 13.
I have tried various ways of "use"ing or "require"ing the necessary packages (even creating a wrapper function I call from within the $body). Nothing seems to work and I always get these errors. I can't seem to catch the first "warning".

Any ideas?

Replies are listed 'Best First'.
Re: Using open3 within a Safe reval
by tigre (Acolyte) on Feb 25, 2010 at 16:59 UTC
    Looks to me like $method is undef at the point at which you execute it. If that is not enough for you to track down this issue, you will have to post more context, such as the instantiation of the compartment and the intervening code.