Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm new to scripting languages but I've been assigned a project where I need to spawn a perl process within tcl code. That perl process will run simultaneously and act as a command console for user input. Based on the commands entered it will pass messsages to the tcl process, or possibly create entries in a queue which is shared between the processes, which the tcl process will examine occasionally (the commands don't need to be immediately responsive). How do you share data structures between a tcl process and a perl process? Or if you can't, is there a simple way to pass messages and data from perl to a tcl process that spawned it?

Replies are listed 'Best First'.
Re: Getting tcl and perl to play along
by fmerges (Chaplain) on Jul 21, 2005 at 23:13 UTC

    Hi,

    If you want to both write to and read from another program. The open function lets you do one or the other, but, you can use the standard IPC::Open2 module for the two-ways-communication:

    use IPC::Open2; open2(*README, *WRITEME, $program); print WRITEME "some input...\n"; $output = <README>; close(WRITEME); close(README);

    Take also a look at: perlipc, IPC::Open2, IPC::Open3 if you need take care of STDERR

    Also in the Perl FAQ 8 you can find info about, perlfaq8.

    Update:Take also a look at XML-RPC, could be interesting for future developments. ;-)

    Regards,

    |fire| at irc.freenode.net

    I like merlyn's disclaimer

Re: Getting tcl and perl to play along
by Courage (Parson) on Jul 22, 2005 at 07:25 UTC