📄 posix.3
字号:
may affect what characters are considered \f(CW\*(C`isgraph\*(C'\fR. Does not workon Unicode characters code point 256 or higher. Consider using regularexpressions and the \f(CW\*(C`/[[:graph:]]/\*(C'\fR construct instead..IP "islower" 8.IX Item "islower"This is identical to the C function, except that it can apply toa single character or to a whole string. Note that locale settingsmay affect what characters are considered \f(CW\*(C`islower\*(C'\fR. Does not workon Unicode characters code point 256 or higher. Consider using regularexpressions and the \f(CW\*(C`/[[:lower:]]/\*(C'\fR construct instead. Do \fBnot\fR use\&\f(CW\*(C`/[a\-z]/\*(C'\fR..IP "isprint" 8.IX Item "isprint"This is identical to the C function, except that it can apply toa single character or to a whole string. Note that locale settingsmay affect what characters are considered \f(CW\*(C`isprint\*(C'\fR. Does not workon Unicode characters code point 256 or higher. Consider using regularexpressions and the \f(CW\*(C`/[[:print:]]/\*(C'\fR construct instead..IP "ispunct" 8.IX Item "ispunct"This is identical to the C function, except that it can apply toa single character or to a whole string. Note that locale settingsmay affect what characters are considered \f(CW\*(C`ispunct\*(C'\fR. Does not workon Unicode characters code point 256 or higher. Consider using regularexpressions and the \f(CW\*(C`/[[:punct:]]/\*(C'\fR construct instead..IP "isspace" 8.IX Item "isspace"This is identical to the C function, except that it can apply toa single character or to a whole string. Note that locale settingsmay affect what characters are considered \f(CW\*(C`isspace\*(C'\fR. Does not workon Unicode characters code point 256 or higher. Consider using regularexpressions and the \f(CW\*(C`/[[:space:]]/\*(C'\fR construct instead, or the \f(CW\*(C`/\es/\*(C'\fRconstruct. (Note that \f(CW\*(C`/\es/\*(C'\fR and \f(CW\*(C`/[[:space:]]/\*(C'\fR are slightlydifferent in that \f(CW\*(C`/[[:space:]]/\*(C'\fR can normally match a vertical tab,while \f(CW\*(C`/\es/\*(C'\fR does not.).IP "isupper" 8.IX Item "isupper"This is identical to the C function, except that it can apply toa single character or to a whole string. Note that locale settingsmay affect what characters are considered \f(CW\*(C`isupper\*(C'\fR. Does not workon Unicode characters code point 256 or higher. Consider using regularexpressions and the \f(CW\*(C`/[[:upper:]]/\*(C'\fR construct instead. Do \fBnot\fR use\&\f(CW\*(C`/[A\-Z]/\*(C'\fR..IP "isxdigit" 8.IX Item "isxdigit"This is identical to the C function, except that it can apply to a singlecharacter or to a whole string. Note that locale settings may affect whatcharacters are considered \f(CW\*(C`isxdigit\*(C'\fR (unlikely, but still possible).Does not work on Unicode characters code point 256 or higher.Consider using regular expressions and the \f(CW\*(C`/[[:xdigit:]]/\*(C'\fRconstruct instead, or simply \f(CW\*(C`/[0\-9a\-f]/i\*(C'\fR..IP "kill" 8.IX Item "kill"This is identical to Perl's builtin \f(CW\*(C`kill()\*(C'\fR function for sendingsignals to processes (often to terminate them), see \*(L"kill\*(R" in perlfunc..IP "labs" 8.IX Item "labs"(For returning absolute values of long integers.)\&\fIlabs()\fR is C\-specific, see \*(L"abs\*(R" in perlfunc instead..IP "ldexp" 8.IX Item "ldexp"This is identical to the C function \f(CW\*(C`ldexp()\*(C'\fRfor multiplying floating point numbers with powers of two..Sp.Vb 1\& $x_quadrupled = POSIX::ldexp($x, 2);.Ve.IP "ldiv" 8.IX Item "ldiv"(For computing dividends of long integers.)\&\fIldiv()\fR is C\-specific, use \f(CW\*(C`/\*(C'\fR and \f(CW\*(C`int()\*(C'\fR instead..IP "link" 8.IX Item "link"This is identical to Perl's builtin \f(CW\*(C`link()\*(C'\fR functionfor creating hard links into files, see \*(L"link\*(R" in perlfunc..IP "localeconv" 8.IX Item "localeconv"Get numeric formatting information. Returns a reference to a hashcontaining the current locale formatting values..SpHere is how to query the database for the \fBde\fR (Deutsch or German) locale..Sp.Vb 10\& $loc = POSIX::setlocale( &POSIX::LC_ALL, "de" );\& print "Locale = $loc\en";\& $lconv = POSIX::localeconv();\& print "decimal_point = ", $lconv\->{decimal_point}, "\en";\& print "thousands_sep = ", $lconv\->{thousands_sep}, "\en";\& print "grouping = ", $lconv\->{grouping}, "\en";\& print "int_curr_symbol = ", $lconv\->{int_curr_symbol}, "\en";\& print "currency_symbol = ", $lconv\->{currency_symbol}, "\en";\& print "mon_decimal_point = ", $lconv\->{mon_decimal_point}, "\en";\& print "mon_thousands_sep = ", $lconv\->{mon_thousands_sep}, "\en";\& print "mon_grouping = ", $lconv\->{mon_grouping}, "\en";\& print "positive_sign = ", $lconv\->{positive_sign}, "\en";\& print "negative_sign = ", $lconv\->{negative_sign}, "\en";\& print "int_frac_digits = ", $lconv\->{int_frac_digits}, "\en";\& print "frac_digits = ", $lconv\->{frac_digits}, "\en";\& print "p_cs_precedes = ", $lconv\->{p_cs_precedes}, "\en";\& print "p_sep_by_space = ", $lconv\->{p_sep_by_space}, "\en";\& print "n_cs_precedes = ", $lconv\->{n_cs_precedes}, "\en";\& print "n_sep_by_space = ", $lconv\->{n_sep_by_space}, "\en";\& print "p_sign_posn = ", $lconv\->{p_sign_posn}, "\en";\& print "n_sign_posn = ", $lconv\->{n_sign_posn}, "\en";.Ve.IP "localtime" 8.IX Item "localtime"This is identical to Perl's builtin \f(CW\*(C`localtime()\*(C'\fR function forconverting seconds since the epoch to a date see \*(L"localtime\*(R" in perlfunc..IP "log" 8.IX Item "log"This is identical to Perl's builtin \f(CW\*(C`log()\*(C'\fR function,returning the natural (\fIe\fR\-based) logarithm of the numerical argument,see \*(L"log\*(R" in perlfunc..IP "log10" 8.IX Item "log10"This is identical to the C function \f(CW\*(C`log10()\*(C'\fR,returning the 10\-base logarithm of the numerical argument.You can also use.Sp.Vb 1\& sub log10 { log($_[0]) / log(10) }.Ve.Spor.Sp.Vb 1\& sub log10 { log($_[0]) / 2.30258509299405 }.Ve.Spor.Sp.Vb 1\& sub log10 { log($_[0]) * 0.434294481903252 }.Ve.IP "longjmp" 8.IX Item "longjmp"\&\fIlongjmp()\fR is C\-specific: use \*(L"die\*(R" in perlfunc instead..IP "lseek" 8.IX Item "lseek"Move the file's read/write position. This uses file descriptors such asthose obtained by calling \f(CW\*(C`POSIX::open\*(C'\fR..Sp.Vb 2\& $fd = POSIX::open( "foo", &POSIX::O_RDONLY );\& $off_t = POSIX::lseek( $fd, 0, &POSIX::SEEK_SET );.Ve.SpReturns \f(CW\*(C`undef\*(C'\fR on failure..IP "malloc" 8.IX Item "malloc"\&\fImalloc()\fR is C\-specific. Perl does memory management transparently..IP "mblen" 8.IX Item "mblen"This is identical to the C function \f(CW\*(C`mblen()\*(C'\fR.Perl does not have any support for the wide and multibytecharacters of the C standards, so this might be a ratheruseless function..IP "mbstowcs" 8.IX Item "mbstowcs"This is identical to the C function \f(CW\*(C`mbstowcs()\*(C'\fR.Perl does not have any support for the wide and multibytecharacters of the C standards, so this might be a ratheruseless function..IP "mbtowc" 8.IX Item "mbtowc"This is identical to the C function \f(CW\*(C`mbtowc()\*(C'\fR.Perl does not have any support for the wide and multibytecharacters of the C standards, so this might be a ratheruseless function..IP "memchr" 8.IX Item "memchr"\&\fImemchr()\fR is C\-specific, see \*(L"index\*(R" in perlfunc instead..IP "memcmp" 8.IX Item "memcmp"\&\fImemcmp()\fR is C\-specific, use \f(CW\*(C`eq\*(C'\fR instead, see perlop..IP "memcpy" 8.IX Item "memcpy"\&\fImemcpy()\fR is C\-specific, use \f(CW\*(C`=\*(C'\fR, see perlop, or see \*(L"substr\*(R" in perlfunc..IP "memmove" 8.IX Item "memmove"\&\fImemmove()\fR is C\-specific, use \f(CW\*(C`=\*(C'\fR, see perlop, or see \*(L"substr\*(R" in perlfunc..IP "memset" 8.IX Item "memset"\&\fImemset()\fR is C\-specific, use \f(CW\*(C`x\*(C'\fR instead, see perlop..IP "mkdir" 8.IX Item "mkdir"This is identical to Perl's builtin \f(CW\*(C`mkdir()\*(C'\fR functionfor creating directories, see \*(L"mkdir\*(R" in perlfunc..IP "mkfifo" 8.IX Item "mkfifo"This is similar to the C function \f(CW\*(C`mkfifo()\*(C'\fR for creating\&\s-1FIFO\s0 special files..Sp.Vb 1\& if (mkfifo($path, $mode)) { .....Ve.SpReturns \f(CW\*(C`undef\*(C'\fR on failure. The \f(CW$mode\fR is similar to themode of \f(CW\*(C`mkdir()\*(C'\fR, see \*(L"mkdir\*(R" in perlfunc, though for \f(CW\*(C`mkfifo\*(C'\fRyou \fBmust\fR specify the \f(CW$mode\fR..IP "mktime" 8.IX Item "mktime"Convert date/time info to a calendar time..SpSynopsis:.Sp.Vb 1\& mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = \-1).Ve.SpThe month (\f(CW\*(C`mon\*(C'\fR), weekday (\f(CW\*(C`wday\*(C'\fR), and yearday (\f(CW\*(C`yday\*(C'\fR) begin at zero.I.e. January is 0, not 1; Sunday is 0, not 1; January 1st is 0, not 1. Theyear (\f(CW\*(C`year\*(C'\fR) is given in years since 1900. I.e. The year 1995 is 95; theyear 2001 is 101. Consult your system's \f(CW\*(C`mktime()\*(C'\fR manpage for detailsabout these and the other arguments..SpCalendar time for December 12, 1995, at 10:30 am..Sp.Vb 2\& $time_t = POSIX::mktime( 0, 30, 10, 12, 11, 95 );\& print "Date = ", POSIX::ctime($time_t);.Ve.SpReturns \f(CW\*(C`undef\*(C'\fR on failure..IP "modf" 8.IX Item "modf"Return the integral and fractional parts of a floating-point number..Sp.Vb 1\& ($fractional, $integral) = POSIX::modf( 3.14 );.Ve.IP "nice" 8.IX Item "nice"This is similar to the C function \f(CW\*(C`nice()\*(C'\fR, for changingthe scheduling preference of the current process. Positivearguments mean more polite process, negative values moreneedy process. Normal user processes can only be more polite..SpReturns \f(CW\*(C`undef\*(C'\fR on failure..IP "offsetof" 8.IX Item "offsetof"\&\fIoffsetof()\fR is C\-specific, you probably want to see \*(L"pack\*(R" in perlfunc instead..IP "open" 8.IX Item "open"Open a file for reading for writing. This returns file descriptors, notPerl filehandles. Use \f(CW\*(C`POSIX::close\*(C'\fR to close the file..SpOpen a file read-only with mode 0666..Sp.Vb 1\& $fd = POSIX::open( "foo" );.Ve.SpOpen a file for read and write..Sp.Vb 1\& $fd = POSIX::open( "foo", &POSIX::O_RDWR );.Ve.SpOpen a file for write, with truncation..Sp.Vb 1\& $fd = POSIX::open( "foo", &POSIX::O_WRONLY | &POSIX::O_TRUNC );.Ve.SpCreate a new file with mode 0640. Set up the file for writing..Sp.Vb 1\& $fd = POSIX::open( "foo", &POSIX::O_CREAT | &POSIX::O_WRONLY, 0640 );.Ve.SpReturns \f(CW\*(C`undef\*(C'\fR on failure..SpSee also \*(L"sysopen\*(R" in perlfunc..IP "opendir" 8.IX Item "opendir"Open a directory for reading..Sp.Vb 3\& $dir = POSIX::opendir( "/var" );\& @files = POSIX::readdir( $dir );\& POSIX::closedir( $dir );.Ve.SpReturns \f(CW\*(C`undef\*(C'\fR on failure..IP "pathconf" 8.IX Item "pathconf"Retrieves the value of a configurable limit on a file or directory..SpThe following will determine the maximum length of the longest allowablepathname on the filesystem which holds \f(CW\*(C`/var\*(C'\fR..Sp.Vb 1\& $path_max = POSIX::pathconf( "/var", &POSIX::_PC_PATH_MAX );.Ve.SpReturns \f(CW\*(C`undef\*(C'\fR on failure..IP "pause" 8.IX Item "pause"This is similar to the C function \f(CW\*(C`pause()\*(C'\fR, which suspendsthe execution of the current process until a signal is received..SpReturns \f(CW\*(C`undef\*(C'\fR on failure..IP "perror" 8.IX Item "perror"This is identical to the C function \f(CW\*(C`perror()\*(C'\fR, which outputs to thestandard error stream the specified message followed by \*(L": \*(R" and thecurrent error string. Use the \f(CW\*(C`warn()\*(C'\fR function and the \f(CW$!\fRvariable instead, see \*(L"warn\*(R" in perlfunc and \*(L"$ERRNO\*(R" in perlvar..IP "pipe" 8.IX Item "pipe"Create an interprocess channel. This returns file descriptors like thosereturned by \f(CW\*(C`POSIX::open\*(C'\fR..Sp.Vb 3\& my ($read, $write) = POSIX::pipe();\& POSIX::write( $write, "hello", 5 );\& POSIX::read( $read, $buf, 5 );.Ve.SpSee also \*(L"pipe\*(R" in perlfunc..IP "pow" 8.IX Item "pow"Computes \f(CW$x\fR raised to the power \f(CW$exponent\fR..Sp.Vb 1\& $ret = POSIX::pow( $x, $exponent );.Ve.SpYou can also use the \f(CW\*(C`**\*(C'\fR operator, see perlop..IP "printf" 8.IX Item "printf"Formats and prints the specified arguments to \s-1STDOUT\s0.See also \*(L"printf\*(R" in perlfunc..IP "putc" 8.IX Item "putc"\&\fIputc()\fR is C\-specific, see \*(L"print\*(R" in perlfunc instead..IP "putchar" 8.IX Item "putchar"\&\fIputchar()\fR is C\-specific, see \*(L"print\*(R" in perlfunc instead..IP "puts" 8.IX Item "puts"\&\fIputs()\fR is C\-specific, see \*(L"print\*(R" in perlfunc instead..IP "qsort" 8.IX Item "qsort"\&\fIqsort()\fR is C\-specific, see \*(L"sort\*(R" in perlfunc instead..IP "raise" 8
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -