in reply to What happens when I use a filehandle

It's better to not open files until you need them. Personally, I think it's better to close them when you're done, but depending on the script it can be ok to leave them for the garbage collector. In my opinion that's just sloppy, but there are reasons to do it.

You can learn a lot about this from the open page alone.

What they do depends on the platform you're on. In *nix there are system calls that get made to the kernel requesting filehandles and readwrites and things. Perl buffers all this stuff and gives you a really nice interface (several actually) to use. In windows, I can only assume it's similar, but don't really know for sure. The details of system level IO represent an enormous discussion that you can safely ignore (for the most part) in perl.

-Paul

  • Comment on Re: What happens when I use a filehandle