(O_APPEND, O_ASYNC, O_CREAT, O_DEFER, O_EXCL, O_NDELAY, O_NONBLOCK,
O_SYNC, O_TRUNC).
-Please refer to your native fcntl() and open() documentation to see
-what constants are implemented in your system.
+For ease of use also the SEEK_* constants (for seek() and sysseek(),
+e.g. SEEK_END) and the S_I* constants (for chmod() and stat()) are
+available for import. They can be imported either separately or using
+the tags C<:seek> and C<:mode>.
+
+Please refer to your native fcntl(2), open(2), fseek(3), lseek(2)
+(equal to Perl's seek() and sysseek(), respectively), and chmod(2)
+documentation to see what constants are implemented in your system.
+
+See L<perlopentut> to learn about the uses of the O_* constants
+with sysopen().
+
+See L<perlfunc/seek> and L<perlfunc/sysseek> about the SEEK_* constants.
+
+See L<perlfunc/stat> about the S_I* constants.
=cut
F_WRDNY
F_WRLCK
O_ACCMODE
+ O_ALIAS
O_APPEND
O_ASYNC
O_BINARY
O_CREAT
O_DEFER
+ O_DIRECT
+ O_DIRECTORY
O_DSYNC
O_EXCL
O_EXLOCK
O_LARGEFILE
O_NDELAY
O_NOCTTY
+ O_NOFOLLOW
O_NONBLOCK
O_RDONLY
O_RDWR
+ O_RSRC
O_RSYNC
O_SHLOCK
O_SYNC
+ O_TEMPORARY
O_TEXT
O_TRUNC
O_WRONLY
- O_ALIAS
- O_RSRC
- SEEK_SET
- SEEK_CUR
- SEEK_END
);
# Other items we are prepared to export if requested
LOCK_NB
LOCK_SH
LOCK_UN
+ S_ISUID S_ISGID S_ISVTX S_ISTXT
+ _S_IFMT S_IFREG S_IFDIR S_IFLNK
+ S_IFSOCK S_IFBLK S_IFCHR S_IFIFO S_IFWHT S_ENFMT
+ S_IRUSR S_IWUSR S_IXUSR S_IRWXU
+ S_IRGRP S_IWGRP S_IXGRP S_IRWXG
+ S_IROTH S_IWOTH S_IXOTH S_IRWXO
+ S_IREAD S_IWRITE S_IEXEC
+ &S_ISREG &S_ISDIR &S_ISLNK &S_ISSOCK &S_ISBLK &S_ISCHR &S_ISFIFO
+ &S_ISWHT &S_ISENFMT &S_IFMT &S_IMODE
+ SEEK_SET
+ SEEK_CUR
+ SEEK_END
);
# Named groups of exports
%EXPORT_TAGS = (
'flock' => [qw(LOCK_SH LOCK_EX LOCK_NB LOCK_UN)],
'Fcompat' => [qw(FAPPEND FASYNC FCREAT FDEFER FDSYNC FEXCL FLARGEFILE
- FNDELAY FNONBLOCK FRSYNC FSYNC FTRUNC)],
+ FNDELAY FNONBLOCK FRSYNC FSYNC FTRUNC)],
+ 'seek' => [qw(SEEK_SET SEEK_CUR SEEK_END)],
+ 'mode' => [qw(S_ISUID S_ISGID S_ISVTX S_ISTXT
+ _S_IFMT S_IFREG S_IFDIR S_IFLNK
+ S_IFSOCK S_IFBLK S_IFCHR S_IFIFO S_IFWHT S_ENFMT
+ S_IRUSR S_IWUSR S_IXUSR S_IRWXU
+ S_IRGRP S_IWGRP S_IXGRP S_IRWXG
+ S_IROTH S_IWOTH S_IXOTH S_IRWXO
+ S_IREAD S_IWRITE S_IEXEC
+ &S_ISREG &S_ISDIR &S_ISLNK &S_ISSOCK
+ &S_ISBLK &S_ISCHR &S_ISFIFO
+ &S_ISWHT &S_ISENFMT
+ &S_IFMT &S_IMODE
+ )],
);
+sub FD_CLOEXEC ();
+
+sub F_ALLOCSP ();
+sub F_ALLOCSP64 ();
+sub F_COMPAT ();
+sub F_DUP2FD ();
+sub F_DUPFD ();
+sub F_EXLCK ();
+sub F_FREESP ();
+sub F_FREESP64 ();
+sub F_FSYNC ();
+sub F_FSYNC64 ();
+sub F_GETFD ();
+sub F_GETFL ();
+sub F_GETLK ();
+sub F_GETLK64 ();
+sub F_GETOWN ();
+sub F_NODNY ();
+sub F_POSIX ();
+sub F_RDACC ();
+sub F_RDDNY ();
+sub F_RDLCK ();
+sub F_RWACC ();
+sub F_RWDNY ();
+sub F_SETFD ();
+sub F_SETFL ();
+sub F_SETLK ();
+sub F_SETLK64 ();
+sub F_SETLKW ();
+sub F_SETLKW64 ();
+sub F_SETOWN ();
+sub F_SHARE ();
+sub F_SHLCK ();
+sub F_UNLCK ();
+sub F_UNSHARE ();
+sub F_WRACC ();
+sub F_WRDNY ();
+sub F_WRLCK ();
+
+sub O_ACCMODE ();
+sub O_ALIAS ();
+sub O_APPEND ();
+sub O_ASYNC ();
+sub O_BINARY ();
+sub O_CREAT ();
+sub O_DEFER ();
+sub O_DIRECT ();
+sub O_DIRECTORY ();
+sub O_DSYNC ();
+sub O_EXCL ();
+sub O_EXLOCK ();
+sub O_LARGEFILE ();
+sub O_NDELAY ();
+sub O_NOCTTY ();
+sub O_NOFOLLOW ();
+sub O_NONBLOCK ();
+sub O_RDONLY ();
+sub O_RDWR ();
+sub O_RSRC ();
+sub O_RSYNC ();
+sub O_SHLOCK ();
+sub O_SYNC ();
+sub O_TEMPORARY ();
+sub O_TEXT ();
+sub O_TRUNC ();
+sub O_WRONLY ();
+
+sub FAPPEND ();
+sub FASYNC ();
+sub FCREAT ();
+sub FDEFER ();
+sub FDSYNC ();
+sub FEXCL ();
+sub FLARGEFILE ();
+sub FNDELAY ();
+sub FNONBLOCK ();
+sub FRSYNC ();
+sub FSYNC ();
+sub FTRUNC ();
+
+sub LOCK_EX ();
+sub LOCK_NB ();
+sub LOCK_SH ();
+sub LOCK_UN ();
+
+sub SEEK_SET ();
+sub SEEK_CUR ();
+sub SEEK_END ();
+
+sub S_ISUID ();
+sub S_ISGID ();
+sub S_ISVTX ();
+sub S_ISTXT ();
+sub _S_IFMT ();
+sub S_IFMT (;$);
+sub S_IMODE ($);
+sub S_IFREG ();
+sub S_IFDIR ();
+sub S_IFLNK ();
+sub S_IFSOCK ();
+sub S_IFBLK ();
+sub S_IFCHR ();
+sub S_IFIFO ();
+sub S_IFWHT ();
+sub S_ENFMT ();
+sub S_IRUSR ();
+sub S_IWUSR ();
+sub S_IXUSR ();
+sub S_IRWXU ();
+sub S_IRGRP ();
+sub S_IWGRP ();
+sub S_IXGRP ();
+sub S_IRWXG ();
+sub S_IROTH ();
+sub S_IWOTH ();
+sub S_IXOTH ();
+sub S_IRWXO ();
+sub S_IREAD ();
+sub S_IWRITE ();
+sub S_IEXEC ();
+
+sub S_IFREG ();
+sub S_IFDIR ();
+sub S_IFLNK ();
+sub S_IFSOCK ();
+sub S_IFBLK ();
+sub S_IFCHR ();
+sub S_IFIFO ();
+sub S_IFWHT ();
+sub S_IFENFMT ();
+
+sub S_IFMT (;$) { @_ ? ( $_[0] & _S_IFMT ) : _S_IFMT }
+sub S_IMODE ($) { $_[0] & 07777 }
+
+sub S_ISREG ($) { ( $_[0] & _S_IFMT ) == S_IFREG }
+sub S_ISDIR ($) { ( $_[0] & _S_IFMT ) == S_IFDIR }
+sub S_ISLNK ($) { ( $_[0] & _S_IFMT ) == S_IFLNK }
+sub S_ISSOCK ($) { ( $_[0] & _S_IFMT ) == S_IFSOCK }
+sub S_ISBLK ($) { ( $_[0] & _S_IFMT ) == S_IFBLK }
+sub S_ISCHR ($) { ( $_[0] & _S_IFMT ) == S_IFCHR }
+sub S_ISFIFO ($) { ( $_[0] & _S_IFMT ) == S_IFIFO }
+sub S_ISWHT ($) { ( $_[0] & _S_IFMT ) == S_ISWHT }
+sub S_ISENFMT ($) { ( $_[0] & _S_IFMT ) == S_ISENFMT }
+
sub AUTOLOAD {
(my $constname = $AUTOLOAD) =~ s/.*:://;
my $val = constant($constname, 0);
";
}
}
- *$AUTOLOAD = sub { $val };
+ *$AUTOLOAD = sub () { $val };
goto &$AUTOLOAD;
}
{
errno = 0;
switch (*name) {
+ case '_':
+ if (strEQ(name, "_S_IFMT")) /* Yes, _S_IFMT. */
+#ifdef S_IFMT
+ return S_IFMT;
+#else
+ goto not_there;
+#endif
+ break;
case 'F':
if (strnEQ(name, "F_", 2)) {
if (strEQ(name, "F_ALLOCSP"))
#else
goto not_there;
#endif
+ if (strEQ(name, "O_DIRECT"))
+#ifdef O_DIRECT
+ return O_DIRECT;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "O_DIRECTORY"))
+#ifdef O_DIRECTORY
+ return O_DIRECTORY;
+#else
+ goto not_there;
+#endif
if (strEQ(name, "O_DSYNC"))
#ifdef O_DSYNC
return O_DSYNC;
#else
goto not_there;
#endif
+ if (strEQ(name, "O_NOFOLLOW"))
+#ifdef O_NOFOLLOW
+ return O_NOFOLLOW;
+#else
+ goto not_there;
+#endif
if (strEQ(name, "O_NONBLOCK"))
#ifdef O_NONBLOCK
return O_NONBLOCK;
#else
goto not_there;
#endif
+ if (strEQ(name, "O_TEMPORARY"))
+#ifdef O_TEMPORARY
+ return O_TEMPORARY;
+#else
+ goto not_there;
+#endif
if (strEQ(name, "O_TEXT"))
#ifdef O_TEXT
return O_TEXT;
goto not_there;
break;
case 'S':
- if (strEQ(name, "SEEK_CUR"))
+ switch (name[1]) {
+ case '_':
+ if (strEQ(name, "S_ISUID"))
+#ifdef S_ISUID
+ return S_ISUID;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "S_ISGID"))
+#ifdef S_ISGID
+ return S_ISGID;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "S_ISVTX"))
+#ifdef S_ISVTX
+ return S_ISVTX;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "S_ISTXT"))
+#ifdef S_ISTXT
+ return S_ISTXT;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "S_IFREG"))
+#ifdef S_IFREG
+ return S_IFREG;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "S_IFDIR"))
+#ifdef S_IFDIR
+ return S_IFDIR;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "S_IFLNK"))
+#ifdef S_IFLNK
+ return S_IFLNK;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "S_IFSOCK"))
+#ifdef S_IFSOCK
+ return S_IFSOCK;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "S_IFBLK"))
+#ifdef S_IFBLK
+ return S_IFBLK;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "S_IFCHR"))
+#ifdef S_IFCHR
+ return S_IFCHR;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "S_IFIFO"))
+#ifdef S_IFIFO
+ return S_IFIFO;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "S_IFWHT"))
+#ifdef S_IFWHT
+ return S_IFWHT;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "S_ENFMT"))
+#ifdef S_ENFMT
+ return S_ENFMT;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "S_IRUSR"))
+#ifdef S_IRUSR
+ return S_IRUSR;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "S_IWUSR"))
+#ifdef S_IWUSR
+ return S_IWUSR;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "S_IXUSR"))
+#ifdef S_IXUSR
+ return S_IXUSR;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "S_IRWXU"))
+#ifdef S_IRWXU
+ return S_IRWXU;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "S_IRGRP"))
+#ifdef S_IRGRP
+ return S_IRGRP;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "S_IWGRP"))
+#ifdef S_IWGRP
+ return S_IWGRP;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "S_IXGRP"))
+#ifdef S_IXGRP
+ return S_IXGRP;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "S_IRWXG"))
+#ifdef S_IRWXG
+ return S_IRWXG;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "S_IROTH"))
+#ifdef S_IROTH
+ return S_IROTH;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "S_IWOTH"))
+#ifdef S_IWOTH
+ return S_IWOTH;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "S_IXOTH"))
+#ifdef S_IXOTH
+ return S_IXOTH;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "S_IRWXO"))
+#ifdef S_IRWXO
+ return S_IRWXO;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "S_IREAD"))
+#ifdef S_IREAD
+ return S_IREAD;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "S_IWRITE"))
+#ifdef S_IWRITE
+ return S_IWRITE;
+#else
+ goto not_there;
+#endif
+ if (strEQ(name, "S_IEXEC"))
+#ifdef S_IEXEC
+ return S_IEXEC;
+#else
+ goto not_there;
+#endif
+ break;
+ case 'E':
+ if (strEQ(name, "SEEK_CUR"))
#ifdef SEEK_CUR
- return SEEK_CUR;
+ return SEEK_CUR;
#else
- goto not_there;
+ return 1;
#endif
- if (strEQ(name, "SEEK_END"))
+ if (strEQ(name, "SEEK_END"))
#ifdef SEEK_END
- return SEEK_END;
+ return SEEK_END;
#else
- goto not_there;
+ return 2;
#endif
- if (strEQ(name, "SEEK_SET"))
+ if (strEQ(name, "SEEK_SET"))
#ifdef SEEK_SET
- return SEEK_SET;
+ return SEEK_SET;
#else
- goto not_there;
+ return 0;
#endif
- break;
+ break;
+ }
}
errno = EINVAL;
return 0;
SCM_CREDS
SCM_RIGHTS
SCM_TIMESTAMP
+ SHUT_RD
+ SHUT_RDWR
+ SHUT_WR
SOCK_DGRAM
SOCK_RAW
SOCK_RDM
}
}
+sub INADDR_ANY ();
+sub INADDR_BROADCAST ();
+sub INADDR_LOOPBACK ();
+sub INADDR_LOOPBACK ();
+
+sub AF_802 ();
+sub AF_APPLETALK ();
+sub AF_CCITT ();
+sub AF_CHAOS ();
+sub AF_DATAKIT ();
+sub AF_DECnet ();
+sub AF_DLI ();
+sub AF_ECMA ();
+sub AF_GOSIP ();
+sub AF_HYLINK ();
+sub AF_IMPLINK ();
+sub AF_INET ();
+sub AF_LAT ();
+sub AF_MAX ();
+sub AF_NBS ();
+sub AF_NIT ();
+sub AF_NS ();
+sub AF_OSI ();
+sub AF_OSINET ();
+sub AF_PUP ();
+sub AF_SNA ();
+sub AF_UNIX ();
+sub AF_UNSPEC ();
+sub AF_X25 ();
+sub IOV_MAX ();
+sub MSG_BCAST ();
+sub MSG_CTLFLAGS ();
+sub MSG_CTLIGNORE ();
+sub MSG_CTRUNC ();
+sub MSG_DONTROUTE ();
+sub MSG_DONTWAIT ();
+sub MSG_EOF ();
+sub MSG_EOR ();
+sub MSG_ERRQUEUE ();
+sub MSG_FIN ();
+sub MSG_MAXIOVLEN ();
+sub MSG_MCAST ();
+sub MSG_NOSIGNAL ();
+sub MSG_OOB ();
+sub MSG_PEEK ();
+sub MSG_PROXY ();
+sub MSG_RST ();
+sub MSG_SYN ();
+sub MSG_TRUNC ();
+sub MSG_URG ();
+sub MSG_WAITALL ();
+sub PF_802 ();
+sub PF_APPLETALK ();
+sub PF_CCITT ();
+sub PF_CHAOS ();
+sub PF_DATAKIT ();
+sub PF_DECnet ();
+sub PF_DLI ();
+sub PF_ECMA ();
+sub PF_GOSIP ();
+sub PF_HYLINK ();
+sub PF_IMPLINK ();
+sub PF_INET ();
+sub PF_LAT ();
+sub PF_MAX ();
+sub PF_NBS ();
+sub PF_NIT ();
+sub PF_NS ();
+sub PF_OSI ();
+sub PF_OSINET ();
+sub PF_PUP ();
+sub PF_SNA ();
+sub PF_UNIX ();
+sub PF_UNSPEC ();
+sub PF_X25 ();
+sub SCM_CONNECT ();
+sub SCM_CREDENTIALS ();
+sub SCM_CREDS ();
+sub SCM_RIGHTS ();
+sub SCM_TIMESTAMP ();
+sub SHUT_RD ();
+sub SHUT_RDWR ();
+sub SHUT_WR ();
+sub SOCK_DGRAM ();
+sub SOCK_RAW ();
+sub SOCK_RDM ();
+sub SOCK_SEQPACKET ();
+sub SOCK_STREAM ();
+sub SOL_SOCKET ();
+sub SOMAXCONN ();
+sub SO_ACCEPTCONN ();
+sub SO_BROADCAST ();
+sub SO_DEBUG ();
+sub SO_DONTLINGER ();
+sub SO_DONTROUTE ();
+sub SO_ERROR ();
+sub SO_KEEPALIVE ();
+sub SO_LINGER ();
+sub SO_OOBINLINE ();
+sub SO_RCVBUF ();
+sub SO_RCVLOWAT ();
+sub SO_RCVTIMEO ();
+sub SO_REUSEADDR ();
+sub SO_SNDBUF ();
+sub SO_SNDLOWAT ();
+sub SO_SNDTIMEO ();
+sub SO_TYPE ();
+sub SO_USELOOPBACK ();
+sub UIO_MAXIOV ();
sub AUTOLOAD {
my($constname);
my ($pack,$file,$line) = caller;
croak "Your vendor has not defined Socket macro $constname, used";
}
- eval "sub $AUTOLOAD { $val }";
+ eval "sub $AUTOLOAD () { $val }";
goto &$AUTOLOAD;
}
#else
goto not_there;
#endif
+ if (strEQ(name, "SHUT_RD"))
+#ifdef SHUT_RD
+ return SHUT_RD;
+#else
+ return 0;
+#endif
+ if (strEQ(name, "SHUT_RDWR"))
+#ifdef SHUT_RDWR
+ return SHUT_RDWR;
+#else
+ return 2;
+#endif
+ if (strEQ(name, "SHUT_WR"))
+#ifdef SHUT_WR
+ return SHUT_WR;
+#else
+ return 1;
+#endif
if (strEQ(name, "SOCK_DGRAM"))
#ifdef SOCK_DGRAM
return SOCK_DGRAM;
* in the face of half-implementations.)
*/
+#ifdef I_SYSMODE
+#include <sys/mode.h>
+#endif
+
#ifndef S_IFMT
# ifdef _S_IFMT
# define S_IFMT _S_IFMT
# define S_ISGID 02000
#endif
+#ifndef S_IRWXU
+# define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
+#endif
+
+#ifndef S_IRWXG
+# define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
+#endif
+
+#ifndef S_IRWXO
+# define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
+#endif
+
+#ifndef S_IREAD
+# define S_IREAD S_IRUSR
+#endif
+
+#ifndef S_IWRITE
+# define S_IWRITE S_IWUSR
+#endif
+
+#ifndef S_IEXEC
+# define S_IEXEC S_IXUSR
+#endif
+
#ifdef ff_next
# undef ff_next
#endif
automatically/transparently added to sysopen() flags if large file
support has been configured), Free/Net/OpenBSD locking behaviour flags
F_FLOCK, F_POSIX, Linux F_SHLCK, and O_ACCMODE: the combined mask of
-O_RDONLY, O_WRONLY, and O_RDWR. Also SEEK_SET, SEEK_CUR, and SEEK_END
-added for one-stop shopping of the seek/sysseek constants.
+O_RDONLY, O_WRONLY, and O_RDWR. The seek()/sysseek() constants
+SEEK_SET, SEEK_CUR, and SEEK_END are available via the C<:seek> tag.
+The chmod()/stat() S_IF* constants and S_IS* functions are available
+via the C<:mode> tag.
+
=item File::Compare
Returns the arctangent of Y/X in the range -PI to PI.
-For the tangent operation, you may use the C<POSIX::tan()>
+For the tangent operation, you may use the C<Math::Trig::tan>
function, or use the familiar relation:
sub tan { sin($_[0]) / cos($_[0]) }
$mode = '0644'; chmod oct($mode), 'foo'; # this is better
$mode = 0644; chmod $mode, 'foo'; # this is best
+You can also import the symbolic C<S_I*> constants from the Fcntl
+module:
+
+ use Fcntl ':mode';
+
+ chmod S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, @executables;
+ # This is identical to the chmod 0755 of the above example.
+
=item chomp VARIABLE
=item chomp LIST
Returns the cosine of EXPR (expressed in radians). If EXPR is omitted,
takes cosine of C<$_>.
-For the inverse cosine operation, you may use the C<POSIX::acos()>
+For the inverse cosine operation, you may use the C<Math::Trig::acos()>
function, or use this relation:
sub acos { atan2( sqrt(1 - $_[0] * $_[0]), $_[0] ) }
instead a Perl builtin. Also see the C<Time::Local> module
(to convert the second, minutes, hours, ... back to seconds since the
stroke of midnight the 1st of January 1970, the value returned by
-time()), and the strftime(3) and mktime(3) function available via the
+time()), and the strftime(3) and mktime(3) functions available via the
POSIX module. To get somewhat similar but locale dependent date
strings, set up your locale environment variables appropriately
(please see L<perllocale>) and try for example:
POSITION, C<1> to set it to the current position plus POSITION, and
C<2> to set it to EOF plus POSITION (typically negative). For WHENCE
you may use the constants C<SEEK_SET>, C<SEEK_CUR>, and C<SEEK_END>
-(start of the file, current position, end of the file) from any of the
-modules Fcntl, C<IO::Seekable>, or POSIX. Returns C<1> upon success,
-C<0> otherwise.
+(start of the file, current position, end of the file) from the Fcntl
+module. Returns C<1> upon success, C<0> otherwise.
If you want to position file for C<sysread> or C<syswrite>, don't use
C<seek>--buffering makes its effect on the file's system position
Returns the sine of EXPR (expressed in radians). If EXPR is omitted,
returns sine of C<$_>.
-For the inverse sine operation, you may use the C<POSIX::asin>
+For the inverse sine operation, you may use the C<Math::Trig::asin>
function, or use this relation:
sub asin { atan2($_[0], sqrt(1 - $_[0] * $_[0])) }
print "$file is executable NFS file\n";
}
-(This works on machines only for which the device number is negative under NFS.)
+(This works on machines only for which the device number is negative
+under NFS.)
Because the mode contains both the file type and its permissions, you
should mask off the file type portion and (s)printf using a C<"%o">
$filename, $sb->size, $sb->mode & 07777,
scalar localtime $sb->mtime;
+You can import symbolic mode constants (C<S_IF*>) and functions
+(C<S_IS*>) from the Fcntl module:
+
+ use Fcntl ':mode';
+
+ $mode = (stat($filename))[2];
+
+ $user_rwx = ($mode & S_IRWXU) >> 6;
+ $group_read = ($mode & S_IRGRP) >> 3;
+ $other_execute = $mode & S_IXOTH;
+
+ printf "Permissions are %04o\n", S_ISMODE($mode), "\n";
+
+ $is_setuid = $mode & S_ISUID;
+ $is_setgid = S_ISDIR($mode);
+
+You could write the last two using the C<-u> and C<-d> operators.
+The commonly available S_IF* constants are
+
+ # Permissions: read, write, execute, for user, group, others.
+
+ S_IRWXU S_IRUSR S_IWUSR S_IXUSR
+ S_IRWXG S_IRGRP S_IWGRP S_IXGRP
+ S_IRWXO S_IROTH S_IWOTH S_IXOTH
+
+ # Setuid/Setgid/Stickiness.
+
+ S_ISUID S_ISGID S_ISVTX S_ISTXT
+
+ # File types. Not necessarily all are available on your system.
+
+ S_IFREG S_IFDIR S_IFLNK S_IFBLK S_ISCHR S_IFIFO S_IFSOCK S_IFWHT S_ENFMT
+
+ # The following are compatibility aliases for S_IRUSR, S_IWUSR, S_IXUSR.
+
+ S_IREAD S_IWRITE S_IEXEC
+
+and the S_IF* functions are
+
+ S_IFMODE($mode) the part of $mode containg the permission bits
+ and the setuid/setgid/sticky bits
+
+ S_IFMT($mode) the part of $mode containing the file type
+ which can be bit-anded with e.g. S_IFREG
+ or with the following functions
+
+ # The operators -f, -d, -l, -b, -c, -p, and -s.
+
+ S_ISREG($mode) S_ISDIR($mode) S_ISLNK($mode)
+ S_ISBLK($mode) S_ISCHR($mode) S_ISFIFO($mode) S_ISSOCK($mode)
+
+ # No direct -X operator counterpart, but for the first one
+ # the -g operator is often equivalent. The ENFMT stands for
+ # record flocking enforcement, a platform-dependent feature.
+
+ S_ISENFMT($mode) S_ISWHT($mode)
+
+See your native chmod(2) and stat(2) documentation for more details
+about the S_* constants.
+
=item study SCALAR
=item study
and C<2> to set it to EOF plus POSITION (typically negative). For
WHENCE, you may also use the constants C<SEEK_SET>, C<SEEK_CUR>, and
C<SEEK_END> (start of the file, current position, end of the file)
-from any of the modules Fcntl, C<IO::Seekable>, or POSIX.
+from the Fcntl module.
Returns the new position, or the undefined value on failure. A position
of zero is returned as the string C<"0 but true">; thus C<sysseek> returns
O_TRUNC Truncate the file
O_NONBLOCK Non-blocking access
-Less common flags that are sometimes available on some operating systems
-include C<O_BINARY>, C<O_TEXT>, C<O_SHLOCK>, C<O_EXLOCK>, C<O_DEFER>,
-C<O_SYNC>, C<O_ASYNC>, C<O_DSYNC>, C<O_RSYNC>, C<O_NOCTTY>, C<O_NDELAY>
-and C<O_LARGEFILE>. Consult your open(2) manpage or its local equivalent
-for details.
+Less common flags that are sometimes available on some operating
+systems include C<O_BINARY>, C<O_TEXT>, C<O_SHLOCK>, C<O_EXLOCK>,
+C<O_DEFER>, C<O_SYNC>, C<O_ASYNC>, C<O_DSYNC>, C<O_RSYNC>,
+C<O_NOCTTY>, C<O_NDELAY> and C<O_LARGEFILE>. Consult your open(2)
+manpage or its local equivalent for details. (Note: starting from
+Perl release 5.6 the O_LARGEFILE flag, if available, is automatically
+added to the sysopen() flags because large files are the the default.)
Here's how to use C<sysopen> to emulate the simple C<open> calls we had
before. We'll omit the C<|| die $!> checks for clarity, but make sure
print "1..0\n# no 64-bit file offsets\n";
exit(0);
}
- require Fcntl; import Fcntl;
+ require Fcntl; import Fcntl qw(/^O_/ /^SEEK_/);
}
sub bye {