in reply to Filehandle open or not - WTF? :(

This line is tripping you up:

open ( LOG, $log ) || warn " Couldn't open log\n" if ($debug);

It'll only open the file if the $debug flag is true. The if is much higher in precedence than ||. This will work instead:

open( LOG, $log ) or do { warn " Couldn't open log: $!\n" if $debug; };