I'm using the following perl code on windows environment:
use Time::HiRes qw(usleep);
#(some code here)
$self->{GLOBAL_OBJ}->xsleep($delay) if($delay);
sub xsleep {
my $seconds = shift;
#print "will sleep:$seconds seconds\n";
$seconds = $seconds * 1000000;
usleep($seconds);
#print "slept:$seconds micro seconds\n";
return 0;
}
When I call xsleep like that (from another module) the system is stuck and I can only stop it by ctrl+c, however when I call it from the current module it works fine.
Can anyone tell me why this is and how can I fix it? Thanks
xsleep
is being called as a method, which means the invocant (the result of the left side of->
) is passed as the first argument. This is currently ending up in$seconds
. References numify to their address, so you get an extremely large numbers in$seconds
. For example,Either adjust
xsleep
so it can be called as a method,or call
xsleep
as a sub