微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

【Perl】 system/exec/readpipe区别

system

system("command",arg0,arg1 ...) 执行命令返回结束状态


exec

The exec function executes a system command and never returns; use system instead of exec if you want it to return. It fails and returns false only if the command does not exist and it is executed directly instead of via your system's command shell (see below).


readpipe

The collected standard output of the command is returned. In scalar context,it comes back as a single (potentially multi-line) string. In list context,returns a list of lines (however you've defined lines with $/ or $INPUT_RECORD_SEParaTOR ).

返回运行结果

my $result = readpipe("ls -l");
print $result;

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐