Shlomi Fish wrote: > On Saturday 31 Oct 2009 02:38:11 Steve Bertrand wrote: >> Steve Bertrand wrote:
>>> 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 }, >>> ); >>> > > This should probably be: (untested) > > <<<< > plan_by_id => sub { return $self->_find_plan_by_id(@_); }, > > See: > > * http://perl-begin.org/tutorials/perl-for-newbies/part3/#page-- > refs_to_funcs--DIR > > (Sorry for the broken URL) No problem. > * http://www.shlomifish.org/lecture/Perl/Newbies/lecture3/refs_to_funcs/ > > (Same resource - only as multiple pages). > >>> # ...obj passed in implicitly as expected >>> $find_commands{ $find_this }( $search_data ); > > This should be: > > {{{ > $find_commands{$find_this}->($search_data) > }}} Beautiful! Even before I review your referenced document, I can already see the fundamental mistakes I was making, and why I was mentally making them. Thanks Shlomi, Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/