If you have a module called "My::Module", and you call "My::Module->some_method", then you'd implement that like:
sub some_method { my ($pkg, @args) = @_;
$pkg->some_other_method;
sub some_method { my ($self, @args) = @_;
A minimal class is just:
package My::Module; sub new { my ($pkg, %opts) = @_; my $self = bless \%opts, $pkg; return $self; } 1;
If you have a module called "My::Module", and you call "My::Module->some_method", then you'd implement that like:
i.e. the module gets passed (as a string) as the first argument. You can then call And similarly, if you have an object "$foo" you would call it like "$foo->some_other_method" and implement it as: i.e. the object gets passed as the first argument. And you can call "$self->some_other_method" with it.A minimal class is just:
Don't let them tell you you need Moo or Moose or Mouse or fields.pm. Hand-rolled objects is the way :)