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

如何在perl脚本中使用perl模块的某个版本(或更高版本)?

我在我的Perl脚本中使用Term :: ANSIColor来对终端输出进行着色,我使用的是colorstrip函数,根据更新日志,它只在Term :: ANSIColor版本2.01中添加.那么,如果它找不到至少那个版本的Term :: ANSIcolor,有没有办法让我的脚本自动死掉一个适当的错误信息?

解决方法

只是:
use Term::ANSIColor 2.01;

perldoc -f use

use Module VERSION LIST

If the VERSION argument is present between Module and LIST,then the use will call the VERSION method in class Module with the given version as an argument. The default VERSION method,inherited from the UNIVERSAL class,croaks if the given version is larger than the value of the variable $Module::VERSION .

原文地址:https://www.jb51.cc/Perl/172139.html

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

相关推荐