IPC::Open2 ought to work for this, but in case it doesn't, you could try saving the output of "function()" to a file, and running the backtick command with redirection of stdin, something like this:
open( CONF, ">function.conf" ) or die $!;
print CONF function();
close CONF;
$result = `program < function.conf`;