Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

fileno

Returns the underlying OS file descriptor for a Perl filehandle.

Returns the numeric file descriptor associated with the given filehandle, or undef if the handle is not connected to a real OS file descriptor (e.g. in-memory handles, closed handles).

Accepts bareword filehandles (STDIN), lexical filehandles ($fh), and IO::Handle / IO::File objects (blessed hashrefs with __fh_id).

The standard streams always return their well-known descriptors: STDIN = 0, STDOUT = 1, STDERR = 2.

Synopsis

$fd = fileno(STDIN);     # 0
$fd = fileno(STDOUT);    # 1
$fd = fileno($fh);       # fd number or undef

See Also

open, close, IO::Handle