run_perl(my_perl) and return value

[email protected] (Yaroslav)
Newsgroups perl.xs
Message-ID <[email protected]>
Hi,

I'm trying to find a way to get 'application return value'.
Just the same as 'package return value', usually 1 or "All your base are 
belong to us" in parent.pm

Is it possible to get the same value from application after running 
something like:

     perl_parse(my_perl, xs_init, argc, argv, (char **)NULL);
     perl_run(my_perl);


Perl app is very simple, just like:

     #!/usr/bin/env perl

     [ qw/some values in arrayref/ ]; # this is return value


Currently I'm using eval replacement:
I call perl_parse with char *my_argv[] = { "", "-e", "0" } and then 
loading Perl app with 'do':

     SV *call = newSVpvf(aTHX_ "sub { do '%s' }", app);
     SV *cvrv = eval_pv(SvPV_nolen(call), FALSE);

     dSP;
     ENTER;
     SAVETMPS;
     PUSHMARK(SP);

     int count = call_sv(cvrv, G_EVAL|G_SCALAR);

     SPAGAIN;
     SV *retval =  (SV*)POPi;

But it looks like hack. Maybe there's better way to run application and 
get it return value?

Cheers,
Yaroslav
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.