$SIG{'ALRM'} = sub { print "Time's up\n"; }; # give it 15 seconds alarm(15); # dbi calls # turn the alarm off alarm(0);