timeout_func($timeout, \&myfunc, $arg1, $arg2); sub timeout_func { my ($timeout, $func, @args) = @_; # ... $func->(@args); }