in reply to Eval tomfoolery...

You probably want:
my $return_value = eval $function;
See the documentation for eval. Just be aware that this does compilation at run-time, so if you're doing a lot of these, your performance will suffer. Unless you need to be re-interpreting the string contained in $function to come up with different Perl code for each try, you should try to think of a way to do this without using eval.