yoda54 has asked for the wisdom of the Perl Monks concerning the following question:
Is it possible to do something like this? I'd like to use eval to generate a bunch of function pointers during runtime and I'd like to be able to pass in and retrieve parameters.
Thanks!
my $a = 'return $_[0] + $_[1];'; print eval $a(3, 5); or perhaps: my $a = 'return $_[0] + $_[1];'; print eval $a->(3, 5);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: eval code generation - parameters & return values
by muba (Priest) on Jun 17, 2012 at 04:46 UTC | |
by yoda54 (Monk) on Jun 17, 2012 at 05:00 UTC | |
|
Re: eval code generation - parameters & return values
by CountZero (Bishop) on Jun 17, 2012 at 08:05 UTC | |
|
Re: eval code generation - parameters & return values
by Khen1950fx (Canon) on Jun 17, 2012 at 16:08 UTC |