eval { open (HANDLE, " $cmdstring |"); alarm $timeout; while (HANDLE) { #process and record info from command's stdout alarm $timeout; #update alarm } alarm 0; }; if ($@) { #timeout occurred #record the fail } else { # do normal stuff }