2010-02-25T09:29:45+01:00

Module::Name->method

package Module::Name;

use Moose;
use Scalar::Util 'blessed';

has 'verbose' => ( is => 'rw', isa => 'Int', default => 1 );

sub method {
    my $self = shift;
    $self = $self->new()
        if not blessed $self;

    print "hell world\n"
        if $self->verbose;

    return;
}

1;

This allows "method" to be called in two ways:

Module::Name->method;
Module::Name->new(verbose => 0)->method;