Hash of functions in modules
From: Vito Corleone (corleone_at_godfather.com)
Date: 11/30/04
- Next message: Tad McClellan: "Re: replace words in string with hash values"
- Previous message: PerlFAQ Server: "FAQ 9.24: How do I fetch a news article or the active newsgroups?"
- Next in thread: Ala Qumsieh: "Re: Hash of functions in modules"
- Reply: Ala Qumsieh: "Re: Hash of functions in modules"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 => \© );
$hof{$cmd}->();
But I will lose the $self in the function. How do I pass $self to the
function too as well?
- Next message: Tad McClellan: "Re: replace words in string with hash values"
- Previous message: PerlFAQ Server: "FAQ 9.24: How do I fetch a news article or the active newsgroups?"
- Next in thread: Ala Qumsieh: "Re: Hash of functions in modules"
- Reply: Ala Qumsieh: "Re: Hash of functions in modules"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]