Perl:将系统命令标准输出重定向到$ variable [英] Perl: Redirect system command stdout to $variable

查看:150
本文介绍了Perl:将系统命令标准输出重定向到$ variable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何将system("valgrind --version")的标准输出(不返回值)重定向到变量$ resultStr,例如$ resultStr应该包含"valgrind-3.7.0"吗?

非常感谢您的帮助.

//W

Hi,

How I can redirect the stdout (NOT the return value) of system("valgrind --version")to a variable $resultStr e.g. the $resultStr should contain "valgrind-3.7.0" ?

Your help is highly appreciated.

//W

推荐答案

resultStr例如
resultStr e.g. the


resultStr应该包含"valgrind-3.7.0"吗?

非常感谢您的帮助.

//W
resultStr should contain "valgrind-3.7.0" ?

Your help is highly appreciated.

//W


您要反引号-请参见引用类似运算符,然后查看qx/STRING/和`STRING`.
You want to backquote that - see Quote Like Operators, and look at qx/STRING/ and `STRING`.


这篇关于Perl:将系统命令标准输出重定向到$ variable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆