sub CheckCache { my $self = shift; my $sub = shift; my $subref = shift; my $time = shift; if (not defined($subtimes{$sub}) or $subtimes{$sub}) < time - $time) { $self->newsub($subref,$sub,$time);} else {goto &$sub;} } sub newsub { my $self = shift; ref $self or die("$self is not an object"); my $subref = shift; my $sub = shift; my $time = shift; $subtimes{$sub} = $time; *$sub = &$subref; # no reason to play this game every time goto &$sub; }