in reply to Subroutine does not sleep
You're calling the array in scalar context, so it's returning the number of elements in it (which is 1). Try using shift: my $time=shift;
Hays