sub add_method { my $class = shift; my $name = shift; my $code = shift; no strict 'refs'; # because you should have strict on *{$class . '::' . $name} = $code; } #### # you must call this as a method, and pass it a CODE ref blort->add_method('foo', sub { print 'bar' }); # now you can do this ... blort::foo();