V
Vito Corleone
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 => \© );
$hof{$cmd}->();
But I will lose the $self in the function. How do I pass $self to the
function too as well?
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 => \© );
$hof{$cmd}->();
But I will lose the $self in the function. How do I pass $self to the
function too as well?