Kevin, sorry to lead you down the wrong path. I had removed my email address and replaced it with
john.doe@xyz.com and I had forgotten to add the "\" before the "@", and yes, $instance and $threshold are global.
When I comment out the local $"; line it works without the error, but all the records of the output_array that go to the email are indented 1 space.