open(QSTAT, 'qstat|') or die("failed to start qstat ($!)"); while () { # Parse output from qstat } close QSTAT or die("close qstat ($!)");