Subject: | Sys::AlarmCall 1.1 - bug for member functions |
Sys::AlarmCall seemed to be exactly what I needed, but I ran into the
following problem:
Trying to use alarm_call() with the object method form fails.
alarm_call( 100, '->func', $obj);
Throws "Can't call method "func" without a package or object
reference".
Removing the unshift from
} elsif ($sub =~ m/^->/) {
unshift(@_,$sub);
$sub = 'shift(@_)' . $sub . '(@_);';
} ...
solves the problem.
Looking at the code, I couldn't work out why the
unshift was there in this case as the function is explicitly built into
the eval string so passing it in again as an argument results in the
above behaviour. The eval line becomes "->func->func()".