Perl   发布时间:2022-04-07  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了模块在“1”中结束,那么它是不会的大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
有一个简单的模块
package Rrr;
use 5.014;
use warnings;
use namespace::sweep;
use Moo;
use Method::Signatures::Simple;

BEGIN {
    our $VERSION = '0.0.1';
}

has 'root' => (
    is => 'rw',default => 'root'
);

method func {
    say 'This is the func method from ' . __PACKAGE__ . ' with value: ',$self->root;
}

1;

谚语-1说

Code is not tidy at line 1,column 1.  See page 33 of PBP.  (Severity: 1)
Module does not end with "1;" at line 17,column 1.  Must end with a recognizable true value.  (Severity: 4)
Return value of flagged function ignored - say at line 18,column 5.  See pages 208,278 of PBP.  (Severity: 1)

如何使百灵达快乐?

编辑 – 基于@ toolic的评论

是的,整洁有助于第一个问题(但代码不整齐在第1行,第1列是不是很有帮助的消息),因为差异是:

13c13
<     is => 'rw',---
>     is      => 'rw',18c18,19
<     say 'This is the func method from ' . __PACKAGE__ . ' with value: ',$self->root;
---
>     say 'This is the func method from ' . __PACKAGE__ . ' with value: ',>       $self->root;

但还是得到:

@H_372_2@module does not end with "1;" at line 17,278 of PBP. (Severity: 1)

我的诡计:

$perlcritic --version
1.125

解决方法

它看起来像Method :: Signatures :: Simple抛出的perlcritic的方法关键字.请注意PPI如何解析以下程序的差异:
$tools/ppidump 'method foo { 1 } 1;'
                    PPI::Document
                      PPI::Statement
[    1,1,1 ]     PPI::Token::Word         'method'
[    1,8,8 ]     PPI::Token::Word         'foo'
                        PPI::Structure::Block   { ... }
                          PPI::Statement
[    1,14,14 ]         PPI::Token::number   '1'
[    1,18,18 ]     PPI::Token::number       '1'
[    1,19,19 ]     PPI::Token::Structure    ';'

$tools/ppidump 'sub foo { 1 } 1;'
                    PPI::Document
                      PPI::Statement::Sub
[    1,1 ]     PPI::Token::Word         'sub'
[    1,5,5 ]     PPI::Token::Word         'foo'
                        PPI::Structure::Block   { ... }
                          PPI::Statement
[    1,11,11 ]         PPI::Token::number   '1'
                      PPI::Statement
[    1,15,15 ]     PPI::Token::number       '1'
[    1,16,16 ]     PPI::Token::Structure    ';'

当使用方法时,整个程序被视为单个语句;当使用sub,1;被视为单独的声明.

为了使perlcritic安静,您可以在方法的关闭括号后添加分号:

@H_372_2@method func { ... }; 1;

或者替代地

@H_372_2@method func { ... } ;1;

不过,我认为amon在评论中提出了一个好点:

大佬总结

以上是大佬教程为你收集整理的模块在“1”中结束,那么它是不会的全部内容,希望文章能够帮你解决模块在“1”中结束,那么它是不会的所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。