Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

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]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2017-06-26 23:47 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (595 votes). Check out past polls.