Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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
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]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2015-11-29 04:51 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (746 votes), past polls