We don't need the close - the filehandle will automatically be closed when it falls out of scope.
Actually that is wrong. FILE globs are not locally scoped.
C:\>type test.pl sub open_file_handle { open FILE, ">c:/test.txt" or die $! } open_file_handle(); print FILE "This file handle is not closed!" or die $! C:\>perl test.pl C:\>type test.txt This file handle is not closed! C:\>
If you really feel that not explicitly closing your filehandles is good programming practice and want to depend on Perl doing it for you you need to use
open my $fh, $file or die $!;
From memory this is only valid for Perl 5.6+
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
In reply to Re: Re: Cannot read in multiple lines
by tachyon
in thread Cannot read in multiple lines
by Angel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |