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;