
Kanji
User
/ Moderator
Jul 25, 2000, 3:23 AM
Post #2 of 3
(499 views)
|
|
Re: how do i run c program within perl?
[In reply to]
|
Can't Post
|
|
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> my $prog = "/path/to/some/program"; exec( "$prog -arg this" ); exec( $prog, "-arg", "this" ); # No shell system( "$prog -arg this" ); system( $prog, "-arg", "this" ); # No shell `$prog -arg this`; # Those are backticks qx/$prog -arg this/; open PROG, "$prog -arg this |"; # Read only open PROG, "| $prog -arg this"; # Write only</pre><HR></BLOCKQUOTE> There are still more methods using open and the special filenames |- and -|. If you can't supply your inneed to read from and write to a process, you'll need to use something like IPC::Open2 or IPC::Open3, or grow your own with pipe and select. See perlipc, and the Functions for processes and process groups section of perlfunc for for more help.
|