我在下面有這個perl代碼,基本上想要循環這兩個文件。然後調用一個bash腳本(它將文件和分隔符作爲參數並打印出多行),然後將該命令的所有輸出保存到一個新文件中(文件名末尾帶有'_processed')。 下面的語法有什麼問題(目前它只是創建一個空白文件)?perl - 將系統命令重定向到一個文件
#!/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'語句正在寫入該文件嗎? – TLP 2012-01-01 14:41:58