while (@list) { if ($pm->start) { # do parent stuff next; } # child stuff goes here $pm->finish; }