tcl脚本到运行 perl代码并输出结果?

tcl script to run perl code and output the results?

我需要通过 tcl 脚本 运行 perl 脚本,但是 tcl 中的 exec 命令没有生成 perl 脚本的结果。

tcl 脚本 (test.tcl) 有以下行

exec perl test.pl

perl 脚本 test.pl 有以下几行。

use strict;
use warnings;
print "Have a nice day!!!";

我 运行通过 cmd window 以 "tclsh test.tcl" 的身份使用 TCL。没有错误也没有输出。为什么会这样???

exec 命令将 return 程序的输出,您必须通过将其保存到变量中来捕获它,或者使用 puts 直接打印它。

set result [exec perl test.pl]
puts $result