如何解决在Perl中执行命令时出现问题
我有以下代码:
chdir glob "/home/test/test1/test2/perl*";
@testList = exec "cat test.in | grep build | awk '{print \$2}'";
foreach my $testList(@testList) {
chdir "/home/test/test1/$testList";
exec "cat test.out | grep -w 'PASSED'";
}
运行上面的代码后,它仅提供以下内容的输出:
chdir glob "/home/test/test1/test2/perl*";
@testList = exec "cat test.in | grep build | awk '{print \$2}'";
,但下面的其他两行除外。我只想要这些行的输出:
foreach my $testList(@testList) {
chdir "$opts->{/home/test/test1$testList";
exec "cat test.out | grep -w 'PASSED'";
不是
chdir glob "/home/test/test1/test2/perl*";
@testList = exec "cat test.in | grep build | awk '{print \$2}'";
请帮助。
解决方法
exec
和system
返回退出代码。
尝试:
@testList = `cat test.in | grep build | awk '{print \$2}'`;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。