spacepaste

  1.  
  2. cat of perlportable.c
  3. -----
  4. #include <EXTERN.h>
  5. #include <perl.h>
  6. #define SAY_HELLO "-e", "$string = $^X; $string =~ s/.*\\///; $newstring = $^X ; $newstring =~ s/$string//; print $newstring;"
  7. int main(int argc, char **argv, char **env)
  8. {
  9. PerlInterpreter *one_perl;
  10. char *one_args[] = { "one_perl", SAY_HELLO };
  11. PERL_SYS_INIT3(&argc,&argv,&env);
  12. one_perl = perl_alloc();
  13. PERL_SET_CONTEXT(one_perl);
  14. perl_construct(one_perl);
  15. perl_parse(one_perl, NULL, 3, one_args, (char **)NULL);
  16. perl_run(one_perl);
  17. perl_destruct(one_perl);
  18. perl_free(one_perl);
  19. PERL_SYS_TERM();
  20. }
  21. -----
  22. executing a.out
  23. /home/zorin-os/Downloads/perl-5.26.0/
  24.