2011-04-26 45 views

回答

5

這是一個Perl FAQ:How can I open a pipe both to and from a command?(簡短的回答:看IPC::Open2

另一種方法是使用I/O重定向設施在你的shell捕捉到你的外部程序的輸出:

open my $qsub_proc, '|-', "qsub $command $args > some/file"; 
print {$qsub_proc} $the_input_to_the_command; 
close $qsub_proc; 

open my $qsub_fh, '<', 'some/file'; 
my @qsub_output = <$qsub_fh>; 
... # now parse @qsub_output to get your job id