or download this
open(FH, '>', $filename) or die "cannot open file";
select FH; # make print() use FH by default
...
# for print(), no other open filehandle has been select()-ed)
print "Three Rings for the Elven-kings under the sky,\n";
# warning: "print() on closed filehandle FH at ..."