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::$!";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Perl fIle handles
by mikeraz (Friar) on Jun 15, 2011 at 17:16 UTC | |
by wind (Priest) on Jun 15, 2011 at 17:55 UTC | |
by lidden (Curate) on Jun 16, 2011 at 06:21 UTC | |
by wind (Priest) on Jun 16, 2011 at 22:17 UTC |
In Section
Seekers of Perl Wisdom