saintex has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,
how can I call static methods in Moose, without create an istance of my class?

I would like to call (like in Java):

Class->staticMethod;

but I can't without create first:
my $o=Class->new;
$o->staticMethod;

Any suggestions?

Replies are listed 'Best First'.
Re: Moose: static methods
by Your Mother (Archbishop) on Apr 04, 2011 at 15:40 UTC

    Probably just write a method (sub). The attributes, has generated methods, are just for objects/instances. Moose is still just plain Perl so-

    package Cow; use Moose; sub static { "Moo"; } package main; print Cow->static, $/;
Re: Moose: static methods
by lamprecht (Friar) on Apr 04, 2011 at 15:43 UTC
    There is nothing special with  new()
    Cheers, CHristoph