English 中文(简体)
• 如何将硬拷贝植入方案? [闭门]
原标题:how to embed perl script in c program? [closed]
  • 时间:2011-06-30 05:41:38
  •  标签:
  • perl

实际上,我只是想说,我需要你帮助。 请允许我说,有什么办法用手稿建立一个图书馆? 我指的是指挥下建立一个图书馆的情况? 以及如何将图书馆纳入我的方案并管理它? 我读到了你能够把你的手稿放在你的手稿中的一些地方,但我怎么做? 我想建立一个专门的图书馆,介绍使用手稿的画面,并在我的节目中使用。 帮助我。 谢谢。

问题回答

To actually include a perl interpreter in your C program and be able to execute perl code, see http://perldoc.perl.org/perlembed.html. Since perl is an interpreted language, there isn t a mandatory step of creating a library from your perl code.

But again, you really need to do some basic reading to learn at least the rudiments of the language first.

Of course, Perl allows you to reuse code by creating modules:

Foo.pm

package Foo;

use strict;
use warnings;

sub bar {
    print "foobar";
}

1;

后来,你可以用以下文字重新使用该守则:

<>条码>foobar.pl

#!/usr/bin/env perl

use strict;
use warnings;

use Foo;

Foo::bar;

Quoting yourself (cody):

Guys perl is not as easy i thought its so confusing thing.

学习 Perl, 浏览书,如:,Perl Beginners Site

在大多数情况下,最佳办法是采用一种系统:

#include <stdlib.h>

int main ()
{
  int RetVal, Arg1, Arg2;
  RetVal=system ("perl Script.pl Arg1 Arg2");
  return 0;
}

如果你也需要分析文字的输出,你可以将其转至档案,并读到C。





相关问题
Why does my chdir to a filehandle not work in Perl?

When I try a "chdir" with a filehandle as argument, "chdir" returns 0 and a pwd returns still the same directory. Should that be so? I tried this, because in the documentation to chdir I found: "...

How do I use GetOptions to get the default argument?

I ve read the doc for GetOptions but I can t seem to find what I need... (maybe I am blind) What I want to do is to parse command line like this myperlscript.pl -mode [sth] [inputfile] I can use ...

Object-Oriented Perl constructor syntax and named parameters

I m a little confused about what is going on in Perl constructors. I found these two examples perldoc perlbot. package Foo; #In Perl, the constructor is just a subroutine called new. sub new { #I ...

Where can I find object-oriented Perl tutorials? [closed]

A Google search yields a number of results - but which ones are the best? The Perl site appears to contain two - perlboot and perltoot. I m reading these now, but what else is out there? Note: I ve ...

热门标签