http://www.perlmonks.org?node_id=919884


in reply to Difference between File Handles and File Descriptors in function parameters.

If I read this Perl Cookbook Chapter 7 I don't see any advantage in using filedescriptors.

Perl's I/O system uses filehandles instead of file descriptors, so you have to make a new filehandle for an already open file descriptor.


s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e

Replies are listed 'Best First'.
Re^2: Difference between File Handles and File Descriptors in function parameters.
by tusty (Novice) on Aug 11, 2011 at 14:57 UTC
    thanks for your response, So what exactly is a file descriptor?? somehow I find that no page I found really answers that question, they just talk about how to use it. Why would any one want to pass or return a file descriptor?

      A file descriptor is a number which specifies a IO stream. In Unix and other POSIX environments, there is an array called the file descriptor table, and you can use a number which indexes one of those entries: 0 is STDIN, 1 is STDOUT, 2 is STDERR ... the remainder you open yourself.

      See Wikipedia's explanation.

      As Occam said: Entia non sunt multiplicanda praeter necessitatem.

      A file descriptor is just a number local to your program, in effect enumerating your open files. Well known file descriptors are 0 (usually pointing to STDIN), 1 (STDOUT) and 2 (STDERR)

      I don't see any advantage in this case, but I'm no expert on this. Maybe it was a miscomunication and he just meant to use $fd filehandles instead of FD filehandles!?