Perl中的系统与反引号和管道之间有什么区别? [英] What's the differences between system and backticks and pipes in Perl?
本文介绍了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:
- 您可以使用反引号和管道轻松获得命令的输出.
- 就是这样(以后会进行更多编辑吗?)
推荐答案
-
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.
这篇关于Perl中的系统与反引号和管道之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文