Once you correct the file handle case problem you will only get something appended to the log file if you cannot open $foo.
It is a good idea, when reporting an error from
open, to always include
$!, which will tell you
why you "Can't write to $foo" (actually, you are not trying to write to $foo, you are trying to open the file for append).
BTW: you can save yourself some keystrokes by using / as the directory separator in your file names, Windows accepts either / or \ (some Windows apps only accept \, but perl is not one of them).
update: I just realised: you are running on UNIX! Why are you using \ for a directory separator in $home?