package Adder; sub new{ my ($class) = @_; my $self = {sum => 0}; bless $self,$class; return $self; } sub connectSum{ my ($self,$var) = @_; $self->{SumVar} = $var; } sub refresh{ my ($self,$old,$new) = @_; $self->{sum} += ($new - $old); $self->{SumVar}->setValueSqrtVar($self->{sum}); } 1;