标量在

use Moose;

extends 'TEST::Role';

has 'name' => (
    is => 'ro',
    isa => 'Str',
    default => 'me',
);

这在 perl 5.8.5 中有效,但在 5.8.8 中无效。

如何解决呢?

String found where operator expected at B.PM line 4, near "extends 'TEST::Role'"
        (Do you need to predeclare extends?)

use Moose;

extends 'TEST::Role';

has 'name' => (
    is => 'ro',
    isa => 'Str',
    default => 'me',
);

This works in perl 5.8.5 but not in 5.8.8.

How to resolve it?

String found where operator expected at B.PM line 4, near "extends 'TEST::Role'"
        (Do you need to predeclare extends?)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

山人契 2024-12-05 21:26:32

如果您可以将其放入失败的测试中并将其发布到 Moose 邮件列表或 irc.perl.org 上的#moose,我相信有人可以帮助解决正在发生的事情。

请务必包含所有代码,这里缺少您的包声明(作为第一个提示,我不会将我的包命名为 B,因为它与核心包冲突)。

If you can get this into a failing test and post it to either the Moose mailing list, or #moose on irc.perl.org I'm sure someone can help sort out what is going on.

Please be sure to include all of the code, your package declaration is missing here (and as a first hint, I wouldn't name my package B because that collides with a core package).

仲春光 2024-12-05 21:26:32

如果没有名为 extends 的函数,就会发生这种情况。也许您安装的 Moose 已损坏或陈旧?也许 use Moose; 之前的行缺少分号?

顺便说一句,您的文件名应该是 .pm,而不是 .PM

That will happen if there is no function named extends. Perhaps you have a broken or old Moose install? Perhaps the line before use Moose; is missing a semi-colon?

By the way, your file name should be .pm, not .PM.

最单纯的乌龟 2024-12-05 21:26:32

你需要把“package xxx;” “使用驼鹿;”之前的行。
这对我有用。

You need to put the "package xxx;" line before "use Moose;".
This worked for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文