in reply to
Perl fIle handles
The second one, a lexical file handle, is better (although you can drop the first line). This is because the file handle is scoped and will be automatically closed and destroyed when perl leaves the block that created it.
You can create a lexical file handle from a fileglob by just taking its reference:
my $sh = \*SHAKESPEARE;
But it is best to open the lexical file handle directly, and the three parameter form of open when write mode:
open my $fh, $file or die "Can't open $file::$!";