in reply to perl debugging problem

It sounds like this script is deployed and running regularly.

What if you add a trace log so that the next time it runs, you can follow the flow of execution and see the data as it goes?
Simply write a little function called debug_trace, that will print $trace_file Dumper shift; You can then paste in calls to that at the beginning of each function plus sprinkled liberally around the area you're interested in. Use it to dump out execution flow tracing labels, along with variable contents so you can replicate the situation in a test environment.

Then you just need to wait for it to be run, and you can see what it did. Put more than enough detail in the first time, so you're less likely to have to go back in later.