in reply to Dynamic Code?
However, if you want $a to be truly dynamic you can use eval to execute the contents of $a, but keep in mind that each time you run it perl has to recompile the eval.
Essentially if you want perl to only compile the function once and you have a couple predefined functions I think setting $a to a function is the way to go, otherwise I guess taking the performance hit from eval and recompiling the code every time $a is executed would be the way to go.
Hopefully this helps give you an idea as to why you would want to use either of the two ways.
Otherwise, if you're looking to do something *really* wackey you could use evals to create static functions ala
This way you can get the performance boost of executing $a through &$a but still have dynamic code from eval.eval '$a = sub { if($joe){somesub($arg1,$arg2);} }'
|
|---|