Skip to content

Instantly share code, notes, and snippets.

@ftdysa
Created December 17, 2013 21:30
Show Gist options
  • Save ftdysa/8012924 to your computer and use it in GitHub Desktop.
Save ftdysa/8012924 to your computer and use it in GitHub Desktop.
sig alarm
eval {
local $SIG{ALRM} = sub { die "timed out" };
alarm 5; # 5 seconds
# do something
alarm 0; # Clears alarm.
};
alarm 0;
if( $@ and $@ =~ /timed out/) {
# there was an error #
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment