in reply to A couple of problems....

I think maybe you could improve performance and make the code more concise by opening and closing the log files only once, at the beginning of the script. Just a thought.

Another (simpler?) way you could handle the errors is with your own error sub...
unlink ($_) or &error(1,"Unable to open file: $_"); sub error { open the log and print out stuff (including $!) if the first variable is 1, exit the script (die style) if the first variable is 0, return to where you were (warn style) }
the advantage of a sub like that is that you can copy it to any script with no modification. It is a lot easier than messing with an error file every time.