Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

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

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1024076]
[choroba]: Yes,
[choroba]: depends on your DNS

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2018-05-21 12:02 GMT
Find Nodes?
    Voting Booth?