spacepaste

  1.  
  2. cat of perlportable.c
  3. -----
  4. #include <EXTERN.h>
  5. #include <perl.h>
  6. /* we're going to embed two interpreters */
  7. #define SAY_HELLO "-e", "$string = $^X; $string =~ s/.*\///; $newstring = $^X ; $newstring =~ s/$string//; print $newstring;"
  8. int main(int argc, char **argv, char **env)
  9. {
  10. PerlInterpreter *one_perl;
  11. char *one_args[] = { "one_perl", SAY_HELLO };
  12. PERL_SYS_INIT3(&argc,&argv,&env);
  13. one_perl = perl_alloc();
  14. PERL_SET_CONTEXT(one_perl);
  15. perl_construct(one_perl);
  16. perl_parse(one_perl, NULL, 3, one_args, (char **)NULL);
  17. perl_run(one_perl);
  18. perl_destruct(one_perl);
  19. perl_free(one_perl);
  20. PERL_SYS_TERM();
  21. }
  22. -----
  23. perlportable.c: In function ‘main’:
  24. perlportable.c:10:46: warning: unknown escape sequence: '\/'
  25. char *one_args[] = { "one_perl", SAY_HELLO };
  26. ^
  27. executing a.out
  28. syntax error at -e line 1, near "/;"
  29. Execution of -e aborted due to compilation errors.
  30.