首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在perl 5.8.8中模拟backticks操作符

在perl 5.8.8中模拟backticks操作符
EN

Stack Overflow用户
提问于 2015-09-09 06:05:24
回答 1查看 145关注 0票数 3

我试图在perl版本5.8.8中模拟backticks操作符。据我所理解,在perl版本5.8.8中不可能模拟它。但是在perl版本5.9中,我可以轻松地使用

*CORE::GLOBAL::readpipe = \&mock_readpipe

有没有办法在perl版本5.8.8中模拟backticks操作符。我能够模拟system(),但不能模仿回退。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-09-09 06:29:15

您可以重写system()和read管道(),因为它们是二等关键字(overridable)。在Perl5.8中,您不能覆盖qx//或, even though they use the same underlying code as readpipe(), simply because they are first-class (non-overridable) keywords. See perl\_keywords.pl and opcode.pl in the Perl source code. Why are some keywords not overridable? The main reason is that those keywords are used as part of some further parsing magic, i.e. they don't follow the usual function call style parsing. The good news is that change [**#29168**](http://www.nntp.perl.org/group/perl.perl5.changes/2006/10/msg16994.html) to perl made qx// overridable. Hooray! That was released in Perl 5.9.5, and will eventually make it to a maintenance release as Perl 5.10.1. When that happens, setting \*CORE::GLOBAL::readpipe will override readpipe(), qx// and

阅读关于僧侣的完整讨论:模拟或捕获系统调用

还可以查看IPC::System::Simple

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32471994

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档