in reply to Rename a Moo constructor from "new" to "run"
The constructor shouldn't be doing extended work. I'd go with the following:
But, you could also go with either of the following:sub run { my ($self) = @_; ... do stuff with $self ... } # In user Class->new(...)->run();
orsub run { my $class = shift; my $obj = $class->new(@_); ... do stuff with $obj ... } # In user Class->run(...);
sub run { my $class = shift; $class->new(@_)->_run(); } sub _run { my ($self) = @_; ... do stuff with $self ... } # In user Class->run(...);
|
|---|