【发布时间】:2013-02-13 06:39:16
【问题描述】:
我在 Windows XP 上使用 Cygwin Perl。
我有这段代码可以运行第三方程序。
sub main {
print("Start Running\n");
@return = run_exe($execApp, $parm1, $parm2);
my $returncode = pop @return;
if ($returncode == 0) {
print("Success\n");
}
else {
print("Error\n");
}
}
sub run_exe {
my ($exe, @parm) = @_;
my (@output, @return_output);
@output = system($exe, @parm);
foreach (@output) {
next if !/\S/; # white space line
s/^(\s*)//g; # trim from the front for $_
s/(\s*)$//g; # trim from the end for $_
push (@return_output, $_);
}
push (@return_output, $?>>8);
@output = ();
return (@return_output);
}
如果成功则打印:
Start Running
Return Code: 0
Success
我想要的不是打印运行 run_exe 子程序的输出(即返回代码:0):
Start Running
Success
我怎样才能做到这一点?请帮帮我,我在 Google 中搜索过,但什么也没找到。
【问题讨论】: