Perl call C programs

Hi,

I am a beginner in Perl programming. Now i need to call a C program from a perl program ...Can any one please help me and give any details how i can do this.

Thanks and Regards

The system() command can invoke any external program. If the C program is not compiled, you need to compile it before you can invoke it (from Perl or otherwise), of course. Or, for an advanced and somewhat complex approach, have a look at the Inline::C module for Perl.

Hi,

Thanks for the quick reference...Will system functions be able return values or just the return code.I need to pass parameters to the C program and return some values.Can you provide a sample?

Thanks and Regards
Jithin.G

if (($retcode = system("ls -l /etc /no/such/file")) == 0) { print "Success (exit code 0)\n"; }
else { print "Error: return code ", $retcode >> 8, "\n"; }

I recommend reading the documentation.

If you want to capture the actual output from an external command, use backticks.