当前位置:首页 » Perl » Perl qx()函数

Perl qx()函数

perl qx()函数例子,qx()函数实例代码 - 是一个替代使用反引号来执行系统命令。

语法

qx EXPR


定义和用法

qx()是一个替代使用反引号来执行系统命令。 例如,qw(LS-L)将执行UNIX的ls命令使用-l命令行选项。实际上,你可以使用任何分隔符,而不仅仅是括号组。

返回值

  • 从执行系统命令的返回值。

例子

试试下面的例子:

#!/usr/bin/perl -w
#by www.gitbook.net

# summarize disk usage for the /tmp directory
# and store the output of the command into the
# @output array.
@output = qx(du -s /tmp);

print "@output\n";

这将产生以下结果:

176     /tmp