tags:

views:

80

answers:

3

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 of 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.

+2  A: 

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.

Marcelo Cantos
A: 

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

Alvin
A: 

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

Sinan Ünür