标量在
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您可以将其放入失败的测试中并将其发布到 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).
如果没有名为
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 beforeuse Moose;
is missing a semi-colon?By the way, your file name should be
.pm
, not.PM
.你需要把“package xxx;” “使用驼鹿;”之前的行。
这对我有用。
You need to put the "package xxx;" line before "use Moose;".
This worked for me.