in reply to dynamic perl code inside my perl program
However, your example doesn't really demonstrate a real need for dynamic code. If all you want is a function that returns one thing, or another depending on the outcome of a comparison, you can just use simple program logic with if statements or the ?: trinary operator.
You may even consider double-barreled-closures as a means of returning a subref to one of several subs depending on the outcome of the logic test.
But eval is always a sure bet for dynamic code.
Dave
|
|---|