alarm(1); while(1) { my $var = "wibble"; $SIG{ALRM} = sub { die "borked on $var"; }; } alarm(0);