#use strict; require DynaLoader; sub test { my ($a, $b, $c, $d) = @_; # Convert the SV into a CV (...I hope) my $code_ref = DynaLoader::dl_install_xsub("main::foo", $a); # An exception occurs on the next line. return "Hello Perl World." . $code_ref->(); }