王朝网络
分享
 
 
 

Perl/TkFAQ-12.10如何在C程序中调用Perl代码?

王朝perl·作者佚名  2008-05-18
宽屏版  字体: |||超大  

原文:

12.10. How do I call perl from C?

You need to see a recent copy of the perlembed(1) pod page. By "recent" it needs to be up to date with at least perl5.002.

Borrowing from Jon Orwant's preamble to that document:

Do you want to: Use C from Perl? Read (at least) the perlcall(1), the perlapi(1), the perlxs(1), the perlxstut(1), and the perlguts(1) manpages. Use C++ from Perl? Recent changes to MakeMaker will make this easier. Be sure you are familiar with the perlcall(1), the perlapi(1), the perlxs(1), the perlxstut(1), and the perlguts(1) manpages. Use an executable program from Perl? Read about backquotes ``, system(), and exec() built in perl functions. Try reading the perlfunc(1) manpage. Use Perl from Perl? Read about do, eval, use and require. The perlfunc(1) manpage discusses these. For complete scripts you may also make use of the backquotes ``, system(), or exec() built in perl functions, but you may take a performance hit in doing so (see perlfunc(1) for information). Use C from C? Rethink your design. Use C++ from C++? See previous. Use Perl from C? Read (at least) the perlembed(1) and the perlguts(1) manpages. Use Perl from C++? Read (at least) the perlembed(1) and the perlguts(1) manpages.

There is also an Doug MacEachern's mailto:dougm@osf.org embedder's development kit on CPAN and at a URL of the following form: http://www.osf.org/~dougm/perl/or http://www.perl.com/cgi-bin/cpan_mod?module=ExtUtils::embed

译文:

12.10 如何在C程序中调用Perl代码?

你应该查阅新近版本的Perl手册页中关于perlembed的内容。这里所谓的“新近版本”应该是至少Perl5.2以上。

(译者注:如果你的系统上已经安装了Perl,那么直接在命令行中使用:perldoc perlembed就可以了。)

下面就是Jon Orwant的手册页的导言部分:(译者注:因为原文可能已经有些过时了,所以下面是按照我自己系统上的Perl手册翻译的。)

如果你需要做下面的事情吗:

在Perl代码中使用C语言?

请阅读perlxstut、perlxs、h2xs、perlguts和perlapi的手册页。

在Perl代码中调用Unix系统程序?

请阅读perlfunc手册页中关于back-quotes,以及"system"和"exec"的部分。

在Perl代码中调用其它的Perl代码?

请阅读perlfunc手册页中关于do、eval、require和use等函数的条目。(译者注:也可以直接使用如下命令行操作:perldoc –f eval等等)

在C程序中调用C程序?

这好像跟我们的话题没有关系咯……:P

在C程序中调用Perl脚本?

读……

另外,互联网上(包括CPAN)还有一个Dong MacEachern开发的专门用于进行嵌入式开发的工具包:

http://www.osf.org/~dougm/perl/

http://www.perl.com/cgi-bin/cpan_mod?module=ExtUtils::embed

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
>>返回首页<<
推荐阅读
 
 
频道精选
 
静静地坐在废墟上,四周的荒凉一望无际,忽然觉得,凄凉也很美
© 2005- 王朝网络 版权所有