#!/usr/bin/perl my $o = Foo->new(); $o->available_methods([ qw/one two/]); $o->one("This will work\n"); $o->two("This will work as well\n"); $o->three("This won't work\n"); package Foo; use Carp; my %Objs; sub new { my $self = {}; $Objs{$self} = {}; bless $self, shift; } sub available_methods { my($self,$methods_ref) = @_; $Objs{$self}{methods} = $methods_ref; } sub DESTROY { my $self = shift; delete $Objs{$self}; } sub AUTOLOAD { my $_call = our $AUTOLOAD; $_call =~ s/.*:://; my $self = shift; my $param = shift; if(grep /$_call/,@{ $Objs{$self}{methods} }) { print $param; } else { carp("Couldn't execute $_call\n"); } }