In all earnestness, I can't understand what the question is. But whatever it is it seems that you want to build perl code as a string, and then to do something "useful" indeed you would
have to
eval it...
Don't!! that is the answer! Use a dispatch table instead.