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

can anyone help me in running tcl scripts in perl.. e.g --> suppose we have a tcl file containing few print statement.. How do i execute the above using perl.. can i get a guide or any doc realted to this.. Thanks

Replies are listed 'Best First'.
Re: running the tcl scripts in perl
by Corion (Patriarch) on Feb 13, 2007 at 08:19 UTC

    Instead of running the Tcl code really embedded inside your Perl code, you might want to just launch the Tcl interpreter with the script and capture the output. The simplest approach would be:

    my $script = 'my_script.tcl'; system($script) == 0 or die "Couldn't launch '$script': $! / $?";

    If you want to capture the output of your script, use backticks:

    my @lines = `$script`;

    There are many other ways, like Open2 and Open3, depending on whether you need to talk to the Tcl script or need to separate the output streams.

Re: running the tcl scripts in perl
by dirving (Friar) on Feb 13, 2007 at 08:53 UTC

    There is also the Tcl module, which implements Perl bindings for the TCL interpreter and also lets you do cool things like tie a Tcl variable to a Perl variable.

    -- David Irving

      It would be better to write the link as [mod://Tcl], which links directly to Tcl.

Re: running the tcl scripts in perl
by jesuashok (Curate) on Feb 13, 2007 at 07:34 UTC

      It would be better to write the link as [mod://Inline::Tcl], which links directly to Inline::Tcl.