home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  



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 returns Perl returns
-1 Undefined value
0 String " 0 but true "
Anything else That 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.