in reply to Match a string only once in a file

Keep track of which ones you've found in a hash.
# assume %matches is declared before the loops ... if ( /$searchstring/i && ! exists($matches{$searchstring}) ) { push @stringsfound, $searchstring; $matches{$searchstring} = 1; } ...
If you dont care about the order the strings were found, you could eliminate the array entirely by initializing the %matches hash with the strings as keys, and the values as false, and set them to true as you find the strings.
Then change my above logic a little.