eval { local $SIG{ALRM} = sub { die "Timed Out" }; alarm 10; ### IO::Socket/Select function call goes here alarm 0; }; if ($@ and $@ !~ /Timed Out/) { die }