my $qsub = qx/qsub -pe mpi 5 -t 1:$filecount:2 $bash/; print "$qsub\n"; # check for sge to finish my $r; my $fileoutcount = $filecount + 2; while($r < $fileoutcount){ opendir(DIR, "./out/BLAST/out") || die "$!"; $r = 0; foreach (readdir DIR){ $r++; } closedir DIR; sleep 500; }