use Carp; $SIG{ALRM} = sub { Carp::cluck("HERE") }; alarm 10; # ... now proceed with files