title: How can a C program call a Perl function?
body: <p>I am invoking a perl subroutine from my C program using <code>call_pv</code>.
  I have 2 questions:</p>
  
  <ol>
  <li><p>How will the C program find in which Perl file this subroutine is defined? Is there any place we can define the Perl file name?</p></li>
  <li><p>If the Perl returns a hash reference as output, how can I read it in C?</p></li>
  </ol>
  
  <p>This is my C function:</p>
  
  <pre><code>static int call_perl_fn(char* image)
  {
  
  dSP;
  int count;
  ENTER;
  SAVETMPS;
  PUSHMARK(SP);
  XPUSHs(sv_2mortal(newSVpv(image, 0))); //parameter to perl subroutine
  PUTBACK;
  count = call_pv("ImageInfo", G_SCALAR); //Invoking ImageInfo subroutine
  SPAGAIN;
  if (count != 1)
  {
      printf("ERROR in call_pv");
  }
  printf("VALUE:%s", (char*)(SvRV(POPp))); //How to read has reference output?
  PUTBACK;
  FREETMPS;
  LEAVE;
  
  return count;
  }
  </code></pre>