Calling a C-function froma Perl script

Hi All,

How can we call a c function from a perl script?
Is it the same way as we do for shell script ?

Thanks in advance
JS

I tried tuning the method to call c function from shell script .. but in vain ..
can some one please help
Thanks
JS

Can you give us an example of what you want to do? It is unusual to attempt to call a C function from a script of any kind.

ya sure ..a very simple example

my sample.c file is given below:

# include <stdio.h>
void pline(void);
main(int argc,char *argv[])
{
int i,j;

printf("Wow Entered main\n");

i=strcmp(argv[0],"pline"); /just to test/
j=strcmp(argv[1],"pline"); /just to test/
printf("i=%d \n j=%d\n",i,j);

if(strcmp(argv[1],"pline") == 0)
{
pline();
printf("done\n");
}
}

void pline(void)
{
int i;
for(i=1;i<5;i++)
printf("Test \n");
printf("\n");
}

No call the function from a 1.pl file .. this is my requirement
i guess we need to get the executable of sample.c after compiling. this too is done and executable is generated.

Thanks

This is the link where i have posted a solution for the shell script

I would describe that as 'running a compiled C programme' rather than 'calling a C function'. You can do that using the system command in perl.

Thanks for pointing this out

But i think system command works only from a c function.
But my need is like have to activate the call from perl script ..
To be frank I dont know anything about system command that well.

Thanks
JS

man perlfunc and search for system LIST.

Can we use swig to do this ?