Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: A Few Questions About IO::File

by talexb (Canon)
on Mar 18, 2013 at 15:06 UTC ( #1024076=note: print w/ replies, xml ) Need Help??


in reply to A Few Questions About IO::File

I get how $fh->close fits your brain better, but you can also consider that the file handle will be closed when the variable holding the filehandle goes out of scope.

So you could do something like this:

use IO::File; { my $fh = IO::File->new('foo', 'r'); # do something with $fh } # The file handle has been automagically closed!
My background is C, so I usually follow an open command with a close command, then go back up and do everything else, but you can use a block to effect the same thing.

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds


Comment on Re: A Few Questions About IO::File
Select or Download Code
Re^2: A Few Questions About IO::File
by rpetrelli (Novice) on Mar 18, 2013 at 15:13 UTC

    I see, thanks for the clarification.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1024076]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2014-09-23 19:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (239 votes), past polls