【发布时间】:2012-01-01 05:04:43
【问题描述】:
我下面有这个perl代码,基本上是想循环这两个文件。然后调用一个 bash 脚本(它将文件和分隔符作为参数并打印出多行),然后将该命令的所有输出保存到一个新文件中(文件名末尾带有“_processed”)。 下面的语法有什么问题(目前它只是创建一个空白文件)?
#!/usr/bin/env perl
use strict;
use warnings;
my(@files) = (
"fixedtt.txt '|'",
"delimd2iffpipe.dat '|'"
);
for my $i (0 .. $#files) {
my($filename) = split /[\s]+/, "$files[$i]", 2;
my($name, $type) = split /[\.]+/, "$filename", 2;
open (MYFILE, '>'."$name".'_processed.'."$type");
system("sh myBashScript.sh $files[$i]"); #I want to write the entire output of this command to a file
close (MYFILE);
}
【问题讨论】:
-
为什么打开和关闭
MYFILE而不打印到它?您认为system语句正在写入该文件吗?
标签: linux perl bash shell unix