Sure. Tested using the below using Active State binary build 1204 (v5.12.3) built for x86_64-linux-thread-multi. This is a Fedora machine.
For some reason, on my Windows XP, Active State v 5.10.1 build 1007 MSWin32-x86-multi-thread, the same code hangs. The alarm() appears to just disappear. Odd. There is often something special about windows. Don't know why this is happening or rather not happening at the moment, but Linux is fine.
Update: I've seen this work on Windows before. Since both machines are running binary Active State builds, I'll retest when I get the Windows machine up to 5.12 along with the latest versions of the modules that I currently have installed. This upgrade is some months in the future...
#!/usr/bin/perl
use warnings;
use strict;
$SIG{ALRM} = sub { die "timeout!!! alarm\n" };
alarm(5); #start the timer
print "waiting for alarm..hit any key...";
<STDIN>;
print "waiting for another input line";
<STDIN>;
print "past the IO stuff, normal exit\n";
__END__
should see this if no key at all is hit
waiting for alarm..hit any key...timeout!!! alarm
|