C/C++ on Linux/Unix

Moderators: Lundin
Number of threads: 336
Number of posts: 663

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Call perl program from C Posted by WeWatch on 8 Dec 2008 at 1:03 PM
I've been trying to call a perl program (an entire program not just a subroutine)and I really don't want to use call() or any exec() functions as I'd like to not have to initialize the perl interpreter each time this program is called.

I've looked at the perlembed stuff but all I can find is ways to call subs or functions not entire programs.

Can anyone help with a link to some sample code? or some suggestions with where to start?

Thank you in advance.
Report
Re: Call perl program from C Posted by gustavo-serra on 12 Feb 2009 at 4:00 AM
Well, this post is rather old. I am returning to Programmers Heaven, so I just saw it.

Ok, my sugesstion is that you could create two pipe files. You would perform this outside from your program. You can see how here.

Then, you will start the execution of your Perl script and instruct it to read/write from/to the pipes that you created. In your C program, you will open both pipes too. Then, all the communication between the perl script and C executable will happen through the pipes. You need to start the perl script only once (I don't know how the script or, to tell the truth, how Perl works).

Hope it helps!



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.