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 PROGRAM LIST
如:
system "abc";
反引号:
`abc`;
通过管道运行:
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屋!
查看全文