in reply to reference to self function

What about:
$self->{funcs}{correlation} = \&Foo::correlation;
? Seems to work here.

Replies are listed 'Best First'.
Re: Re: reference to self function
by anjiro (Beadle) on Jun 25, 2003 at 07:05 UTC
    Unfortunately in the real code, it looks like a call doesn't include $self as an argument. Apologies for not making that need clear earlier. For example, making correlation look like:
    sub correlation { my($self, @args) = @_; print "self is $self, there are @args args\n"; }
    and creating a new function bar that looks like:
    sub bar { my $self = shift; $self->{funcs}{$self->{method}}(); }
    When we do:
    my $x = new Foo; $x->bar;
    the output is errors about uninitialized values, and self is , there are  args

    dan

      Ah, then perhaps you want:
      $self->{funcs}{correlation} = sub { $self->correlation(@_) };
      ?
        Ooh, yeah! That works great! Thanks a bunch!

        dan