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

Re: Difference between File Handles and File Descriptors in function parameters.

by Skeeve (Vicar)
on Aug 11, 2011 at 14:45 UTC ( #919884=note: print w/ replies, xml ) Need Help??


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


Comment on Re: Difference between File Handles and File Descriptors in function parameters.
Select or Download Code
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!?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://919884]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (10)
As of 2015-07-31 08:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (276 votes), past polls