open(QSTAT, 'qstat|') or $self->_die("failed to start qstat ($!)"); while () { # Read the results, act on them } close QSTAT or ($! ? $self->_die("close qstat ($!)") : $logger->error("close qstat ($?)") );