Actually I've got an idea but to do that I need your help.Tell me is there any way to create a library in perl script ? I mean what is the command to create a library in perl ?and how can i include that library in my c program and run it ? I read somewhere that you can embedd your perl script in your c program but how can I make it?I want to create a special library on strings using perl script and use it in my c program.Help me guys.Thank you.
To actually include a perl interpreter in your C program and be able to execute perl code, see http://perldoc.perl.org/perlembed.html. Since perl is an interpreted language, there isn't a mandatory step of creating a library from your perl code.
But again, you really need to do some basic reading to learn at least the rudiments of the language first.
Of course, Perl allows you to reuse code by creating modules:
Foo.pm
package Foo;
use strict;
use warnings;
sub bar {
print "foobar";
}
1;
Later, you could reuse the code in a script like:
foobar.pl
#!/usr/bin/env perl
use strict;
use warnings;
use Foo;
Foo::bar;
Quoting yourself (cody):
Guys perl is not as easy i thought its so confusing thing.
To learn Perl, try following a book like Learning Perl, or tutorials on the internet like Perl Beginners' Site or Learn Perl.
In most cases, the best way to do it is by a system call:
#include <stdlib.h>
int main ()
{
int RetVal, Arg1, Arg2;
RetVal=system ("perl Script.pl Arg1 Arg2");
return 0;
}
If you also need to analyze the script's output, you can redirect it to a file and read the file in C.
精彩评论