- or download this
package UsesClosures;
...
sub get_attr { &{ shift->{get_attr } } };
sub set_attr { &{ shift->{set_attr } } };
sub some_method { &{ shift->{some_method} } };
- or download this
my $o = UsesClosures->new();
$o->set_attr(123);
print $o->get_attr();
$o->some_method();
- or download this
package Dinner;
...
sub wash_hands { &{ shift->{wash_hands} } };
sub eat_food { &{ shift->{eat_food } } };
- or download this
my $dirtyeater = Dinner->new();
$dirtyeater->wash_hands();
$dirtyeater->eat_food();