Perl中的系统与反引号和管道之间有什么区别?

问题描述:

Perl支持三种(我知道)运行外部程序的方式:

Perl supports three ways (that I know of) of running external programs:

system:

   system PROGRAM LIST

如:

system "abc";

反引号,如:

`abc`;

通过管道运行它,如下所示:

running it through a pipe as in:

open ABC, "abc|";

它们之间有什么区别?这就是我所知道的:

What are the differences between them? Here's what I know:

  1. 您可以使用反引号和管道轻松获得命令的输出.
  2. 就是这样(以后会进行更多编辑吗?)

  • system():运行命令并返回命令的退出状态
  • 反引号:运行命令并返回命令的输出
  • pipes:运行命令,并允许您将它们用作句柄
    • system(): runs command and returns command's exit status
    • backticks: runs command and returns the command's output
    • pipes : runs command and allows you to use them as an handle
    • 反引号也将执行的程序的STDOUT重定向到变量,然后系统将其发送到主程序的STDOUT.

      Also backticks redirects the executed program's STDOUT to a variable, and system sends it to your main program's STDOUT.