for my $index (0 .. $#threads - 1) { if ($threads[$index] =~ /$parent/) { if ($threads[$index +1] eq '