目录

qx

描述 (Description)

此函数是使用反引号执行系统命令的替代方法。 例如,qx(ls -l)将使用-l命令行选项执行UNIX ls命令。 您实际上可以使用任何一组分隔符,而不仅仅是括号。

语法 (Syntax)

以下是此函数的简单语法 -

qx EXPR

返回值 (Return Value)

此函数返回执行的系统命令中的值。

例子 (Example)

以下是显示其基本用法的示例代码 -

#!/usr/bin/perl -w
# 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
↑回到顶部↑
WIKI教程 @2018