如何將Perl直譯器嵌入到C#程式中
我意識到我必須DllImport的perlembed方法
perl_parse perl_alloc perl_free
等等.,
但不知道如何使用與DLLImport一起使用的函式引數,特別是使用perl_parse方法.
我也意識到,一個ofollow,noindex" target="_blank">related question 已經存在,幾乎在那裡,但仍然通過建立一個C包裝器,然後在C#中使用它解決了OP.
他說他不能DLLimport PERL_SYS_INIT3.
所以我的問題是如何正確地包裝他們只使用C#並使用它?
看這個;我希望它會有所幫助(它被稱為早期版本)
要在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