Thanks for your suggestions. See the post above for an example that causes a crash. I did try using
our, but it didn't make a difference. The lexicals are not getting thrown away, because the program produces the correct output. It is just a matter of the interpreter crashing after the script is finished, probably during garbage collection.
When's the last time you used duct tape on a duct? --Larry Wall