开发者

How can I execute a Perl script inside C++ console application?

I am new to C++ programming :). I was wondering what would be the best and easiest approach for this problem.

I have a C++ console application and a Perl script. Both o开发者_如何学运维f them are to be integrated. To be more specific need to write perl perlscript.pl arg1 in a cmd prompt (to execute the Perl script). perform few actions in C++ console and keep changing the arguments ( arg1... and so on). there is a limit on the arguments in Perl script that depend upon outcome of my C++ console application.

I could write a Perl script using the Win32API module to pass commands to different command prompts and get results and so on. But this is very inefficient way of doing things.

I would appreciate for a much better solution or direction to think.


It's only "very inefficient" if it has a noticeable impact on the performance of your program. Since it is very easy to call the system() function, you should try this first and see for yourself. Only then should you consider other options.

Since any other approach is going involve considerably more work, trying to improve the code before profiling it is premature optimisation.


If you do decide to embed perl in your program, see perldoc perlembed.


You can use the exec functions for this. Here is the reference.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜