Perl in a Nutshell

Perl in a NutshellSearch this book
Previous: Reference: expChapter 5
Function Reference
Next: Reference: fileno
 

fcntl

fcntl filehandle, function, arg

Calls the file control function (with the function-specific arg) to use on the file or device opened with filehandle. fcntl calls Unix's fcntl function (not available on Win32 platforms). If the function is not implemented, the program exits with a fatal error. fcntl sets file descriptors for a filehandle. This built-in command is usable when you use the Fcntl module in the standard distribution:

use Fcntl;
This module imports the correct function definitions. See the description of the Fcntl module in Chapter 8, Standard Modules.

The return value of fcntl (and ioctl) is as follows:

System call returnsPerl returns
-1Undefined value
0String "0 but true"
Anything elseThat number

Thus Perl returns true on success and false on failure, yet you can still easily determine the actual value returned by the operating system.


Previous: Reference: expPerl in a NutshellNext: Reference: fileno
Reference: expBook IndexReference: fileno

Library Navigation Links

Copyright © 2001 O'Reilly & Associates. All rights reserved.