Hash of functions in modules

From: Vito Corleone (corleone_at_godfather.com)
Date: 11/30/04


Date: Tue, 30 Nov 2004 14:12:19 +0900

Hi,

I have code like this:

if ($cmd eq "get") { $self->get(); }
elsif ($cmd eq "set") { $self->set(); }
elsif ($cmd eq "copy") { $self->copy(); }

I want to put it inside hash of function. How do I do that? I know I can
do:

%hof = ( get => \&get,
         set => \&set,
         copy => \&copy );
$hof{$cmd}->();

But I will lose the $self in the function. How do I pass $self to the
function too as well?