Take over STDOUT / STDERR for Perl embedded in C application

Discussion in 'Perl Misc' started by William, Oct 5, 2005.

  1. William

    William Guest


    I am trying to embed Perl in a C++ application. I have a window that
    takes input, when user hits return, the input is sent to Perl for
    evaluation. I then want to display the input back to the user in the
    window and display it differently for error versus normal output.

    I've searched the web, but can't seem to find a clear example of how to
    do this in C.

    Presently, after calling result = perl_eval_pv() to eval the user
    input, I do SvPV(result, PL_sa) and the result goes to my window. The
    result is a code indicating success etc.

    However, this leaves stdout and stderr still going to the shell where
    my app was launched.

    I would like a pointer to an example of this kind of thing being done
    so I can emmulate it.

    I've found many places where this question is asked but no clear


    William, Oct 5, 2005
    1. Advertisements

  2. This is more a question about C++ than Perl, so you're a bit offtopic.
    Try a C++ or C newsgroup.

    Now, if you wanted, I expect you could probably run the C program from
    Perl, and for that, the IPC::Open3 module would be useful. (I haven't
    been able to find a C/C++ equivalent. I suspect it may involve multiple

    If you've still got your heart set on running the perl from the C, I
    suppose you could open a couple FIFOs.
    Chris Johnson, Oct 5, 2005
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.