There are several ways to execute Perl programs from Tcl applications. Most succinct is simply to apply Tcl's powerful exec in a command such as
exec my_program.pl
[Explain open, and other IPC, more generally.]
It's quick work in Tcl to code a
proc perl_interpret scripte { return [exec perl << [uplevel [list subst -novariables -noback $script]]] }
which allows one to write
set a 13 set b 79 puts [perl_interpret { $result = [set a] + [set b]; print "The sum is ", $result, ".\n"; }]
Phil Ehrens offers a slightly more elaborate version:
proc perl { args } { set perl_opts -e foreach arg $args { if { [ regexp {^-+\S+$} $arg ] } { set perl_opts [ concat $arg $perl_opts ] } else { lappend perl_code $arg } } puts stderr "perl $perl_opts $perl_code" catch {eval exec perl $perl_opts $perl_code } result }
An example usage of this is
perl "print \"foo!\"; print \"bar\""
Tclperl is quite nice. So is the Perl widget, although in a much different way.