alarm
use Socket;
eval {
local $SIG{ALRM} = sub { die "time is out" };
alarm 3;
socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp');
connect SOCK, sockaddr_in(81, inet_aton("microsoft.com"))
or die "connect failed";
alarm 0;
send SOCK, "GET / HTTP/1.0\n\n", 0;
print while <SOCK>;
shutdown SOCK, 2;
};
print "$@\n" if $@;
die
$warnings = 0;
$SIG{__WARN__} = sub { print @_ if $warnings };
$SIG{__DIE__} = sub { print "Goodbye, my darling!\n" };
warn "i'm only warning...";
die "i'm dying...";
(Read more)