for my $strChain (@arrWorkingCompletedChains) { my $found = false; foreach (@arrWorkingCompletedChains) { if ($strChain ne $_ && index($_, $strChain) >= 0) { $found = true; last; } } if (!$found) { push(@arrCompletedChains, $strChain); } }