我注意到有关处理此问题的其他几个问题,但似乎都受到了影响:
我想做的是调用一个程序(例如tshark.exe)并在其运行时处理它的输出。
到目前为止,我已尝试过:
答案 0 :(得分:4)
您不需要模块。只需了解open
命令的管道形式 - 这些在Windows上运行正常。
my $pid = open (my $cmd_handle, "tshark.exe @options |");
# on success, $pid holds process identifier of the external command.
while (<$cmd_handle>) {
# sets $_ to next line of output.
# Will block until a line of output is ready.
# Is undef when the command is complete.
... process $_ ...
}
close $cmd_handle; # waits for command to complete if it hasn't completed yet
答案 1 :(得分:0)
结帐IPC::Run
。 IPC::Open2
和IPC::Open3
也可能满足您的需求。