executing perl script (as char*, not file) in C and evaluating @ARGV

Discussion in 'Perl Misc' started by Torsten Mohr, Dec 17, 2003.

  1. Torsten Mohr

    Torsten Mohr Guest

    Hi,

    i'd like to write a C program that allocates a
    PerlInterpreter* and executes a script that is
    contained as a "char*" in the C program. I don't
    want to load the script from a file.
    The parameters that the C program gets should be
    available in the perl script.

    I looked through "perldoc perlembed" and "perlapi",
    but i didn't find anything that really matches this.

    "perl_parse" seems to be necessary to get @ARGV, but
    if i don't pass {"", "-e", "0"} to it, it tries to
    get input from stdin.

    If i leave perl_parse away, the C program crashes.

    Also, adding a line like "PERL_SYS_INIT3(&argc, &argv, &env);"
    neither at the beginning nor before eval_pv(script_pointer, TRUE)
    didn't help.


    Has anybody got an example C program, that:

    - executes a script that resides in memory
    - makes @ARGV available to that script
    - doesn't try to get input from stdin

    I didn't find anything googling for it or in the source
    tarball.


    thanks for any hints,
    Torsten.
    Torsten Mohr, Dec 17, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bret

    char **argv vs. char* argv[]

    Bret, Aug 31, 2003, in forum: C Programming
    Replies:
    21
    Views:
    4,583
    Richard Heathfield
    Sep 3, 2003
  2. David
    Replies:
    10
    Views:
    5,951
    Richard Heathfield
    Sep 15, 2003
  3. Hal Styli
    Replies:
    14
    Views:
    1,629
    Old Wolf
    Jan 20, 2004
  4. jab3

    char **argv & char *argv[]

    jab3, Dec 4, 2004, in forum: C Programming
    Replies:
    5
    Views:
    665
    Chris Torek
    Dec 8, 2004
  5. oogie
    Replies:
    9
    Views:
    656
    Default User
    Nov 18, 2007
Loading...

Share This Page