Name

fcntl

Synopsis

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 functiondefinitions. See the description of the Fcntl module in Chapter 8.

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.

Get Perl in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.