- #include <EXTERN.h>
-
#include <perl.h>
-
-
static PerlInterpreter *my_perl;
-
-
char buf[BUFSIZ];
-
-
main (int argc, char **argv, char **env)
-
{
-
STRLEN n_a;
-
SV *my;
-
-
char *embedding[] = {"", "-e", "0"};
-
PERL_SYS_INIT3(&argc,&argv,&env);
-
my_perl = perl_alloc();
-
perl_construct( my_perl );
-
perl_parse(my_perl, NULL, 3, embedding, NULL);
-
PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
-
perl_run(my_perl);
-
-
sprintf(buf, "$text=%s;\n%s", "xxxxxxxbbbbbbbbbbgggggeeeeeeee", "if ($text =~ /(b+)/){$a=$1;};");
-
eval_pv(buf, TRUE);
-
printf("a = %s\n", SvPV(get_sv("a", FALSE), n_a));
-
-
/*
-
eval_pv("$b; $a = 'rekcaH lreP=1234 rehtonA tsuJ'; if($a =~ /lreP=(\\d+)/){$b=$1};", TRUE);
-
printf("b = %s\n", SvPV(get_sv("b", FALSE), n_a));
-
*/
-
-
perl_destruct(my_perl);
-
perl_free(my_perl);
-
PERL_SYS_TERM();
-
}
gcc plcc.cpp -L/usr/lib/perl5/core_perl/CORE/ -I/usr/lib/perl5/core_perl/CORE/ -lperl -lm