my $o = Anything->new(qw/foo bar baz/); $o->bar; package Anything; use strict; use warnings; sub new { my ($class, @methods) = @_; my $self = bless {}, $class; for my $method (@methods) { no strict 'refs'; *$method = sub { print "this is method $method\n" }; } return $self; }