Steve Bertrand wrote:
Hi all,
Hello,
Within a CGI environment, I'm trying to do a dispatch table test, but
can't figure out how to call the coderef as a method. Here is the
working code. I'll describe what doesn't work afterwards:
sub perform_find {
my $self = shift;
my $find_this = $self->query->param( 'find_this' );
my $search_data = $self->query->param( 'search_data' );
my %find_commands = (
# call by local function
plan_by_id => \&_find_plan_by_id,
);
# and pass in $self explicitly
$find_commands{ $find_this }( $self, $search_data );
}
__END__
Things progress properly using the above. What I don't understand, is
why I have to pass in $self as a param to the dispatch table. What
didn't work is this:
sub perform_find {
my $self = shift;
my $find_this = $self->query->param( 'find_this' );
my $search_data = $self->query->param( 'search_data' );
my %find_commands = (
# I'm trying to call the method on myself
plan_by_id => \&{ $self->_find_plan_by_id },
);
# ...obj passed in implicitly as expected
$find_commands{ $find_this }( $search_data );
}
__END__
...or any variant of trying to use the method-call syntax within a
dispatch table coderef.
How and where is _find_plan_by_id() defined?
John
--
The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity. -- Damian Conway
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/