Username: Password:

Perl/TkFAQ-12.10怎样在C程式中调用Perl代码?
来源:linux宝库作者:linux宝库 发布时间:2007-09-30 00:00:00


  原文:

  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

喜欢本文,那就收藏到:

    Del.icio.us Google书签 Digg Live Bookmark Technorati Furl Yahoo书签 Facebook 百度搜藏 新浪ViVi 365Key网摘 天极网摘 和讯网摘 博拉网 POCO网摘 添加到饭否 QQ书签 Digbuzz我挖网
相关评论  我也要评论
还没有关于此文章的相关评论!
  • 昵称: (为空则显示guest)
  • 评论分数: ★ ★ ★★★ ★★★★ ★★★★★
  • 评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
  • 导航
    赞助商
    文章类别
    订阅