in reply to How can I save error message to a file?

If it's a special run, you can just redirect (./foo 2> /path/to/testlog.txt) from the command line. Otherwise,

open local(*STDERR), '>>', '/path/to/testlog.txt' or die $! if $TESTING;
You can remove the "if $TESTING" clause if you want to log all errors from this code. If you do that, you may want to include a timestamp in your warnings and dying words.

After Compline,
Zaxo