나는이 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