📄 posix.pod
字号:
Returns the process identifier. Identical to Perl's builtinvariable C<$$>, see L<perlvar/$PID>.=item getppidThis is identical to Perl's builtin C<getppid()> function forreturning the process identifier of the parent process of the currentprocess , see L<perlfunc/getppid>.=item getpwnamThis is identical to Perl's builtin C<getpwnam()> function forreturning user entries by user names, see L<perlfunc/getpwnam>.=item getpwuidThis is identical to Perl's builtin C<getpwuid()> function forreturning user entries by user identifiers, see L<perlfunc/getpwuid>.=item getsReturns one line from C<STDIN>, similar to E<lt>E<gt>, also knownas the C<readline()> function, see L<perlfunc/readline>.B<NOTE>: if you have C programs that still use C<gets()>, be veryafraid. The C<gets()> function is a source of endless grief becauseit has no buffer overrun checks. It should B<never> be used. TheC<fgets()> function should be preferred instead.=item getuidReturns the user's identifier. Identical to Perl's builtin C<$E<lt>> variable,see L<perlvar/$UID>.=item gmtimeThis is identical to Perl's builtin C<gmtime()> function forconverting seconds since the epoch to a date in Greenwich Mean Time,see L<perlfunc/gmtime>.=item isalnumThis is identical to the C function, except that it can apply to asingle character or to a whole string. Note that locale settings mayaffect what characters are considered C<isalnum>. Does not work onUnicode characters code point 256 or higher. Consider using regularexpressions and the C</[[:alnum:]]/> construct instead, or possiblythe C</\w/> construct.=item isalphaThis 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 C<isalpha>. Does not workon Unicode characters code point 256 or higher. Consider using regularexpressions and the C</[[:alpha:]]/> construct instead.=item isattyReturns a boolean indicating whether the specified filehandle is connectedto a tty. Similar to the C<-t> operator, see L<perlfunc/-X>.=item iscntrlThis 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 C<iscntrl>. Does not workon Unicode characters code point 256 or higher. Consider using regularexpressions and the C</[[:cntrl:]]/> construct instead.=item isdigitThis 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 C<isdigit> (unlikely, butstill possible). Does not work on Unicode characters code point 256or higher. Consider using regular expressions and the C</[[:digit:]]/>construct instead, or the C</\d/> construct.=item isgraphThis 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 C<isgraph>. Does not workon Unicode characters code point 256 or higher. Consider using regularexpressions and the C</[[:graph:]]/> construct instead.=item islowerThis 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 C<islower>. Does not workon Unicode characters code point 256 or higher. Consider using regularexpressions and the C</[[:lower:]]/> construct instead. Do B<not> useC</[a-z]/>.=item isprintThis 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 C<isprint>. Does not workon Unicode characters code point 256 or higher. Consider using regularexpressions and the C</[[:print:]]/> construct instead.=item ispunctThis 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 C<ispunct>. Does not workon Unicode characters code point 256 or higher. Consider using regularexpressions and the C</[[:punct:]]/> construct instead.=item isspaceThis 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 C<isspace>. Does not workon Unicode characters code point 256 or higher. Consider using regularexpressions and the C</[[:space:]]/> construct instead, or the C</\s/>construct. (Note that C</\s/> and C</[[:space:]]/> are slightlydifferent in that C</[[:space:]]/> can normally match a vertical tab,while C</\s/> does not.)=item isupperThis 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 C<isupper>. Does not workon Unicode characters code point 256 or higher. Consider using regularexpressions and the C</[[:upper:]]/> construct instead. Do B<not> useC</[A-Z]/>.=item isxdigitThis 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 C<isxdigit> (unlikely, but still possible).Does not work on Unicode characters code point 256 or higher.Consider using regular expressions and the C</[[:xdigit:]]/>construct instead, or simply C</[0-9a-f]/i>.=item killThis is identical to Perl's builtin C<kill()> function for sendingsignals to processes (often to terminate them), see L<perlfunc/kill>.=item labs(For returning absolute values of long integers.)labs() is C-specific, see L<perlfunc/abs> instead.=item ldexpThis is identical to the C function C<ldexp()>for multiplying floating point numbers with powers of two. $x_quadrupled = POSIX::ldexp($x, 2);=item ldiv(For computing dividends of long integers.)ldiv() is C-specific, use C</> and C<int()> instead.=item linkThis is identical to Perl's builtin C<link()> functionfor creating hard links into files, see L<perlfunc/link>.=item localeconvGet numeric formatting information. Returns a reference to a hashcontaining the current locale formatting values.Here is how to query the database for the B<de> (Deutsch or German) locale. $loc = POSIX::setlocale( &POSIX::LC_ALL, "de" ); print "Locale = $loc\n"; $lconv = POSIX::localeconv(); print "decimal_point = ", $lconv->{decimal_point}, "\n"; print "thousands_sep = ", $lconv->{thousands_sep}, "\n"; print "grouping = ", $lconv->{grouping}, "\n"; print "int_curr_symbol = ", $lconv->{int_curr_symbol}, "\n"; print "currency_symbol = ", $lconv->{currency_symbol}, "\n"; print "mon_decimal_point = ", $lconv->{mon_decimal_point}, "\n"; print "mon_thousands_sep = ", $lconv->{mon_thousands_sep}, "\n"; print "mon_grouping = ", $lconv->{mon_grouping}, "\n"; print "positive_sign = ", $lconv->{positive_sign}, "\n"; print "negative_sign = ", $lconv->{negative_sign}, "\n"; print "int_frac_digits = ", $lconv->{int_frac_digits}, "\n"; print "frac_digits = ", $lconv->{frac_digits}, "\n"; print "p_cs_precedes = ", $lconv->{p_cs_precedes}, "\n"; print "p_sep_by_space = ", $lconv->{p_sep_by_space}, "\n"; print "n_cs_precedes = ", $lconv->{n_cs_precedes}, "\n"; print "n_sep_by_space = ", $lconv->{n_sep_by_space}, "\n"; print "p_sign_posn = ", $lconv->{p_sign_posn}, "\n"; print "n_sign_posn = ", $lconv->{n_sign_posn}, "\n";=item localtimeThis is identical to Perl's builtin C<localtime()> function forconverting seconds since the epoch to a date see L<perlfunc/localtime>.=item logThis is identical to Perl's builtin C<log()> function,returning the natural (I<e>-based) logarithm of the numerical argument,see L<perlfunc/log>.=item log10This is identical to the C function C<log10()>,returning the 10-base logarithm of the numerical argument.You can also use sub log10 { log($_[0]) / log(10) }or sub log10 { log($_[0]) / 2.30258509299405 }or sub log10 { log($_[0]) * 0.434294481903252 }=item longjmplongjmp() is C-specific: use L<perlfunc/die> instead.=item lseekMove the file's read/write position. This uses file descriptors such asthose obtained by calling C<POSIX::open>. $fd = POSIX::open( "foo", &POSIX::O_RDONLY ); $off_t = POSIX::lseek( $fd, 0, &POSIX::SEEK_SET );Returns C<undef> on failure.=item mallocmalloc() is C-specific. Perl does memory management transparently.=item mblenThis is identical to the C function C<mblen()>.Perl does not have any support for the wide and multibytecharacters of the C standards, so this might be a ratheruseless function.=item mbstowcsThis is identical to the C function C<mbstowcs()>.Perl does not have any support for the wide and multibytecharacters of the C standards, so this might be a ratheruseless function.=item mbtowcThis is identical to the C function C<mbtowc()>.Perl does not have any support for the wide and multibytecharacters of the C standards, so this might be a ratheruseless function.=item memchrmemchr() is C-specific, see L<perlfunc/index> instead.=item memcmpmemcmp() is C-specific, use C<eq> instead, see L<perlop>.=item memcpymemcpy() is C-specific, use C<=>, see L<perlop>, or see L<perlfunc/substr>.=item memmovememmove() is C-specific, use C<=>, see L<perlop>, or see L<perlfunc/substr>.=item memsetmemset() is C-specific, use C<x> instead, see L<perlop>.=item mkdirThis is identical to Perl's builtin C<mkdir()> functionfor creating directories, see L<perlfunc/mkdir>.=item mkfifoThis is similar to the C function C<mkfifo()> for creatingFIFO special files. if (mkfifo($path, $mode)) { ....Returns C<undef> on failure. The C<$mode> is similar to themode of C<mkdir()>, see L<perlfunc/mkdir>, though for C<mkfifo>you B<must> specify the C<$mode>.=item mktimeConvert date/time info to a calendar time.Synopsis: mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = -1)The month (C<mon>), weekday (C<wday>), and yearday (C<yday>) begin at zero.I.e. January is 0, not 1; Sunday is 0, not 1; January 1st is 0, not 1. Theyear (C<year>) is given in years since 1900. I.e. The year 1995 is 95; theyear 2001 is 101. Consult your system's C<mktime()> manpage for detailsabout these and the other arguments.Calendar time for December 12, 1995, at 10:30 am. $time_t = POSIX::mktime( 0, 30, 10, 12, 11, 95 ); print "Date = ", POSIX::ctime($time_t);Returns C<undef> on failure.=item modfReturn the integral and fractional parts of a floating-point number. ($fractional, $integral) = POSIX::modf( 3.14 );=item niceThis is similar to the C function C<nice()>, 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.Returns C<undef> on failure.=item offsetofoffsetof() is C-specific, you probably want to see L<perlfunc/pack> instead.=item openOpen a file for reading for writing. This returns file descriptors, notPerl filehandles. Use C<POSIX::close> to close the file.Open a file read-only with mode 0666. $fd = POSIX::open( "foo" );Open a file for read and write. $fd = POSIX::open( "foo", &POSIX::O_RDWR );Open a file for write, with truncation. $fd = POSIX::open( "foo", &POSIX::O_WRONLY | &POSIX::O_TRUNC );Create a new file with mode 0640. Set up the file for writing. $fd = POSIX::open( "foo", &POSIX::O_CREAT | &POSIX::O_WRONLY, 0640 );Returns C<undef> on failure.See also L<perlfunc/sysopen>.=item opendirOpen a directory for reading. $dir = POSIX::opendir( "/var" ); @files = POSIX::readdir( $dir ); POSIX::closedir( $dir );Returns C<undef> on failure.=item pathconfRetrieves the value of a configurable limit on a file or directory.The following will determine the maximum length of the longest allowablepathname on the filesystem which holds C</var>. $path_max = POSIX::pathconf( "/var", &POSIX::_PC_PATH_MAX );Returns C<undef> on failure.=item pauseThis is similar to the C function C<pause()>, which suspendsthe execution of the current process until a signal is received.Returns C<undef> on failure.=item perrorThis is identical to the C function C<perror()>, which outputs to thestandard error stream the specified message followed by ": " and thecurrent error string. Use the C<warn()> function and the C<$!>variable instead, see L<perlfunc/warn> and L<perlvar/$ERRNO>.=item pipeCreate an interprocess channel. This returns file descriptors like thosereturned by C<POSIX::open>. my ($read, $write) = POSIX::pipe(); POSIX::write( $write, "hello", 5 ); POSIX::read( $read, $buf, 5 );See also L<perlfunc/pipe>.=item powComputes C<$x> raised to the power C<$exponent>. $ret = POSIX::pow( $x, $exponent );You can also use the C<**> operator, see L<perlop>.=item printfFormats and prints the specified arguments to STDOUT.See also L<perlfunc/printf>.=item putcputc() is C-specific, see L<perlfunc/print> instead.=item putcharputchar() is C-specific, see L<perlfunc/print> instead.=item putsputs() is C-specific, see L<perlfunc/print> instead.=item qsortqsort() is C-specific, see L<perlfunc/sort> instead.=item raiseSends the specified signal to the current process.See also L<perlfunc/kill> and the C<$$> in L<perlvar/$PID>.=item randC<rand()> is non-portable, see L<perlfunc/rand> instead.=item readRead from a file. This uses file descriptors such as those obtained bycalling C<POSIX::open>. If the buffer C<$buf> is not large enough for theread then Perl will extend it to make room for the request. $fd = POSIX::open( "foo", &POSIX::O_RDONLY ); $bytes = POSIX::read( $fd, $buf, 3 );Returns C<undef> on failure.See also L<perlfunc/sysread>.=item readdirThis is identical to Perl's builtin C<readdir()> functionfor reading directory entries, see L<perlfunc/readdir>.=item reallocrealloc() is C-specific. Perl does memory management transparently.=item removeThis is identical to Perl's builtin C<unlink()> functionfor removing files, see L<perlfunc/unlink>.=item renameThis is identical to Perl's builtin C<rename()> functionfor renaming files, see L<perlfunc/rename>.=item rewindSeeks to the beginning of the file.=item rewinddirThis is identical to Perl's builtin C<rewinddir()> function forrewinding directory entry streams, see L<perlfunc/rewinddir>.=item rmdirThis is identical to Perl's builtin C<rmdir()> functionfor removing (empty) directories, see L<perlfunc/rmdir>.=item scanfscanf() is C-specific, use E<lt>E<gt> and regular expressions instead,see L<perlre>.=item setgidSets the real group identifier and the effective group identifier forthis process. Similar to assigning a value to the Perl's builtinC<$)> variable, see L<perlvar/$EGID>, except that the latterwill change only the real user identifier, and that the setgid()uses only a single numeric argument, as opposed to a space-separatedlist of numbers.=item setjmpC<setjmp()> is C-specific: use C<eval {}> instead,see L<perlfunc/eval>.=item setlocaleModifies and queries program's locale. The following examples assume use POSIX qw(setlocale LC_ALL LC_CTYPE);has been issued.The following will set the traditional UNIX system locale behavior(the second argument C<"C">). $loc = setlocale( LC_ALL, "C" );The following will query the current LC_CTYPE category. (No secondargument means 'query'.) $loc = setlocale( LC_CTYPE );The following will set the LC_CTYPE behaviour according to the localeenvironment variables (the second argument C<"">).Please see your systems C<setlocale(3)> documentation for the localeenvironment variables' meaning or consult L<perllocale>. $loc = setlocale( LC_CTYPE, "" );The following will set the LC_COLLATE behaviour to ArgentinianSpanish. B<NOTE>: The naming and availability of locales depends onyour operating system. Please consult L<perllocale> for how to findout which locales are available in your system. $loc = setlocale( LC_ALL, "es_AR.ISO8859-1" );=item setpgidThis is similar to the C function C<setpgid()> forsetting the process group identifier of the current process.Returns C<undef> on failure.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -