如何通过引用C XS模块传递Perl数组?
my @array = ( 1..20 );
XSTEST::test_array_passing(\@array);
Run Code Online (Sandbox Code Playgroud)
我在XS中做什么让它看到阵列?
我正在学习perl Inline :: Python库.在cpan网站的例子中,我们有
print "9 + 16 = ", add(9, 16), "\n";
print "9 - 16 = ", subtract(9, 16), "\n";
use Inline Python => <<'END_OF_PYTHON_CODE';
def add(x,y):
return x + y
def subtract(x,y):
return x - y
END_OF_PYTHON_CODE
Run Code Online (Sandbox Code Playgroud)
是否可以将python代码放入字符串中,以便我可以在运行时创建python代码?例如,类似于:
my $python_code = "
def add(x,y):
return x + y
";
print $python_code;
use Inline Python => "$python_code";
print "9 + 16 = ", add(9, 16), "\n";
Run Code Online (Sandbox Code Playgroud)
我们有一个项目将在运行时动态创建python函数.我们想要调用这些函数.是py_eval()的方法吗?提前致谢.