open $foo, $tempfilename; print $foo "\n"; close $foo; # probably redundant, but why not. open $foo, $tempfilename; binmode $foo; read $foo, $result, 999; close $foo;