如何将Perl解释器嵌入到C#程序中

栏目: C# · 发布时间: 7年前

内容简介:代码日志版权声明:翻译自:http://stackoverflow.com/questions/10176058/how-to-embed-the-perl-interpreter-in-a-c-sharp-program

我意识到我必须DllImport的perlembed方法

perl_parse
perl_alloc
perl_free

等等.,

但不知道如何使用与DLLImport一起使用的函数参数,特别是使用perl_parse方法.

我也意识到,一个 related question 已经存在,几乎在那里,但仍然通过创建一个C包装器,然后在C#中使用它解决了OP.

他说他不能DLLimport PERL_SYS_INIT3.

所以我的问题是如何正确地包装他们只使用C#并使用它?

看这个;我希望它会有所帮助(它被称为早期版本)

我从这里得到这个( perl )

要在C#程序中嵌入 Perl 解释器,请添加对COM对象“Microsoft Script Control 1.0”的引用,并编写如下代码:

MSScriptControl.ScriptControlClass Interpreter;
Interpreter = new MSScriptControl.ScriptControlClass();
Interpreter.Language = @"PerlScript";
string Program = @"reverse 'abcde'";
string Results = (string)Interpreter.Eval(Program);

以上内容相当于以下Perl脚本,它在Perl解释器中嵌入Perl解释器:

use Win32::OLE;
my $Interpreter;
$Interpreter = Win32::OLE->new('ScriptControl');
$Interpreter->{Language} = 'PerlScript';
my $Program = "reverse 'abcde'";
my $Results = $Interpreter->Eval($Program);

代码日志版权声明:

翻译自:http://stackoverflow.com/questions/10176058/how-to-embed-the-perl-interpreter-in-a-c-sharp-program


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Web Security, Privacy and Commerce, 2nd Edition

Web Security, Privacy and Commerce, 2nd Edition

Simson Garfinkel / O'Reilly Media / 2002-01-15 / USD 44.95

Since the first edition of this classic reference was published, World Wide Web use has exploded and e-commerce has become a daily part of business and personal life. As Web use has grown, so have ......一起来看看 《Web Security, Privacy and Commerce, 2nd Edition》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

URL 编码/解码
URL 编码/解码

URL 编码/解码

MD5 加密
MD5 加密

MD5 加密工具