On 10/18/11 10:02 AM, Peter Gordon wrote:
I would like to be able to define package MyRole such that when it is
invoked, runMe() gets run automatically without having to run
it explicitly in package Y.
This has nothing to do with Moose. It's the same for any module. You can do
something like
package Foo;
runMe();
sub runMe {
...
} # end runMe()
1;
When a module gets loaded, it first gets compiled and then the code in the file scope
gets run. This is how the module does its return of a true value: the result of require
is the last value returned by execution of the module, which is traditionally handled by
putting a "1;" at the end.