Clear questions and runnable code
get the best and fastest answer
moose role that uses a class that does the roleby mjbetts (Initiate)
|on Jun 28, 2012 at 12:14 UTC||Need Help??|
mjbetts has asked for the
wisdom of the Perl Monks concerning the following question:
I have a moose role and two classes that do it. However, the role uses one of these classes. Is this kind of circularity allowed? I'm getting an error that I don't understand - an instance does a role but can't find a method defined in that role.
I've tried to write the simplest set of code that replicates the problem:
And then a script test.pl that uses these:
When I run test.pl I get the following error:
Greeting=HASH(0x8e5da40) does Hello Can't locate object method "hello_world" via package "Greeting" at ./test.pl line 9.
How come Greeting does Hello but can't locate the hello_world method? If I 'use Greeting' before 'use Greeting2', or if I don't 'use Greeting' in Hello.pm, I don't get the error.
I'd be really grateful if you could point me in the right direction.