in reply to problem writing to a file handle
Output to files is buffered. If you wait long enough, the output will also show up in the file.
If you really want the output to be unbuffered (thus slowing down your program somewhat), see perlvar about $|:
my $oldfh = select(LOG); $| = 1; select($oldfh);
|
|---|