Steve Bertrand wrote:
> Steve Bertrand wrote:
>> Hi all,
>>
>> 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 );

&{ $find_commands{ $find_this } }( $search_data );

>> }
>>
>> __END__
>>
>> ...or any variant of trying to use the method-call syntax within a
>> dispatch table coderef.
> 
> I suppose I should have actually asked a question ;)
> 
> Can anyone point out what I am missing?
> 
> Steve
> 


-- 
Just my 0.00000002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

I like Perl; it's the only language where you can bless your
thingy.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to