in reply to Hash of subroutines as member of a class
The problem is that you are calling the subroutine as a normal function rather than as an object method. Try changing to:
Also, it would be easier to assign to ACTIVITIES without the de-reference:my $method = $this->{ACTIVITIES}->{$this->{ACT}}->{'func'}; $this->$method($arg);
Within an object, you don't need to take a reference to the subroutine, so you could just have:$this->{ACTIVITIES} = { Sale => {}, .... };
$this->{ACTIVITIES} = { Sale => { func => 'total_sold', datefield => 'date_sold', }, Purchase => { func => 'total_bought', datefield => 'date_bought', }, };
|
|---|