# named constants for portability use Fcntl qw( F_GETFL O_WRONLY O_RDONLY O_RDWR); if ( (O_WRONLY | O_RDWR) & fcntl( FOO, F_GETFL, 0) ) { # g'wan and write }