use strict; use warnings; use diagnostics; use 5.014; my $newbook = Lib::Book->new( isbn => 'ISBN', ); say $newbook->isbn; package Lib::Book; use Moo; has isbn => ( is => 'rw', ); 1;
My code, in which I can see no material differences from the documentation (http://search.cpan.org/~haarg/Moo-1.004002/lib/Moo.pm), crashes as follows:
Z:\Data\Library\Dancer2>sopw.pl Can't locate object method "isbn" via package "Lib::Book" at Z:\Data\Library\Dancer2\sopw.pl line 9 (#1) (F) You called a method correctly, and it correctly indicated a pa +ckage functioning as a class, but that package doesn't define that parti +cular method, nor does any of its base classes. See perlobj. Uncaught exception from user code: Can't locate object method "isbn" via package "Lib::Book" at Z +:\Data\Library\Dancer2\sopw.pl line 9.
I'm slightly surprised by the error message's reference to an "object method" when I'm trying to address a property, but I suspect that this is merely a Perl idiosyncracy. The assignment in the "new" command works - printing the object using Data::Dumper reveals the isbn property set as I would expect. I tried inserting the "namespace::clean" line from the docs, but that changed nothing.
What should I look at next, please?
Regards,
John Davies
In reply to Moo error message not understood by davies
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |