in reply to getting the return value from a C program

Is there a way to get the value 5 from that C program?
Yes, examine the value of $? after system (or backticks) has returned.

I know I can do a printf (or cout) and capture the standard out in the perl script, but is there a way to in-line a C function/program and get the return value?
Sure! You could do an XS interface, or use Inline::C.

The main reason I am asking this is to get the output from the C function gettimeofday so that I can get the time at micro second granularity.
Oh!No need to complicate then: just use Time::HiRes, and it will make gettimeofday available to you as a function.

  • Comment on Re: getting the return value from a C program