- or download this
my %dispatch = (
Foo => \&_foo,
Bar => \&_bar,
...
my $method = $dispatch{$type} || die "Can't find method ...";
$self->$method($data);
}
- or download this
multimethod process (Foo $thing, String $data) { ... }
multimethod process (Bar $thing, String $data) { ... }
multimethod process (Baz $thing, String $data) { ... }
- or download this
sub name {
my ($self, $name) = @_;
$self->{name} = $name if $name;
return $self->{name};
}