use strict; use warnings; my $timeout = 2; eval { local $SIG{ALRM} = sub { die "alarm\n" }; alarm $timeout; here: goto here; printf "Got past the goto!\n"; alarm 0; }; print "ERROR: $@" if $@; #### ERROR: alarm