Hi there, I'm trying out the module IO::File and one thing confuses me: how do I properly close the file? The IO::File synopsis section demonstrates two ways to close the file either with:
or with:use IO::File; my $fh = IO::File->new('foo', 'r'); # do something with $fh undef $fh;
# continuing from above $fh->close;
Coming from python background, the second method fits better in my brain, but I'm not sure if this is the correct way especially since the $fh variable is still defined:
# The output is something like IO::File=GLOB(yadda yadda) print "$fh" if defined $fh;
Somewhat related, I tried this code to get a list of lines from a file:
my @lines = IO::File->new('foo')->getlines;
It's very convenient, but this isn't mentioned anywhere in the doc and I'm not sure whether this has any negative side effects.
In reply to A Few Questions About IO::File by rpetrelli
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |