This is exactly what the
perl debugger is for. You can step through the program line by line and check values of variables at any point. You say that the program is too long to do backtraces on, but it seems to me that it would be quicker to spend an hour in the debugger than 4 hours adding debugging statements in your code.
BlueLines
Disclaimer:
This post may contain inaccurate information, be habit forming, cause atomic warfare between peaceful countries, speed up male pattern baldness, interfere with your cable reception, exile you from certain third world countries, ruin your marriage, and generally spoil your day. No batteries included, no strings attached, your mileage may vary.