Philip Potter wrote:
Dear all,

I'm trying to learn to use the IO::File object as a means of passing a
filehandle from one function to another. In the perldoc documentation
for IO::File, it gives the example:

undef $fh;       # automatically closes the file

but in the reference that follows, it gives no indication for why this
might be the case. Would this behaviour be caused by the destructor?

Yes.

If $fh goes out of scope, will the file be automatically closed?

Yes.

> If
not, why does undef $fh; close the file and how would I find this out
in the reference manual?

It is consider best practise to explicitly close the file so you can test for errors:

close $fh or die "could not close file: $!";


--
Just my 0.00000002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

I like Perl; it's the only language where you can bless your
thingy.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to