📄 perlfunc.1
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...de Sp \" Vertical space (when we can't use .PP).if t .sp .5v.if n .sp...de Vb \" Begin verbatim text.ft CW.nf.ne \\$1...de Ve \" End verbatim text.ft R.fi...\" Set up some character translations and predefined strings. \*(-- will.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left.\" double quote, and \*(R" will give a right double quote. \*(C+ will.\" give a nicer C++. Capital omega is used to do unbreakable dashes and.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,.\" nothing in troff, for use with C<>..tr \(*W-.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'.ie n \{\. ds -- \(*W-. ds PI pi. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch. ds L" "". ds R" "". ds C` "". ds C' ""'br\}.el\{\. ds -- \|\(em\|. ds PI \(*p. ds L" ``. ds R" '''br\}.\".\" Escape single quotes in literal strings from groff's Unicode transform..ie \n(.g .ds Aq \(aq.el .ds Aq '.\".\" If the F register is turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD. Of course, you'll have to process the.\" output yourself in some meaningful fashion..ie \nF \{\. de IX. tm Index:\\$1\t\\n%\t"\\$2"... nr % 0. rr F.\}.el \{\. de IX...\}.\".\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2)..\" Fear. Run. Save yourself. No user-serviceable parts.. \" fudge factors for nroff and troff.if n \{\. ds #H 0. ds #V .8m. ds #F .3m. ds #[ \f1. ds #] \fP.\}.if t \{\. ds #H ((1u-(\\\\n(.fu%2u))*.13m). ds #V .6m. ds #F 0. ds #[ \&. ds #] \&.\}. \" simple accents for nroff and troff.if n \{\. ds ' \&. ds ` \&. ds ^ \&. ds , \&. ds ~ ~. ds /.\}.if t \{\. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u". ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'.\}. \" troff and (daisy-wheel) nroff accents.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'.ds 8 \h'\*(#H'\(*b\h'-\*(#H'.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#].ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#].ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#].ds ae a\h'-(\w'a'u*4/10)'e.ds Ae A\h'-(\w'A'u*4/10)'E. \" corrections for vroff.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'. \" for low resolution devices (crt and lpr).if \n(.H>23 .if \n(.V>19 \\{\. ds : e. ds 8 ss. ds o a. ds d- d\h'-1'\(ga. ds D- D\h'-1'\(hy. ds th \o'bp'. ds Th \o'LP'. ds ae ae. ds Ae AE.\}.rm #[ #] #H #V #F C.\" ========================================================================.\".IX Title "PERLFUNC 1".TH PERLFUNC 1 "2007-12-18" "perl v5.10.0" "Perl Programmers Reference Guide".\" For nroff, turn off justification. Always turn off hyphenation; it makes.\" way too many mistakes in technical documents..if n .ad l.nh.SH "NAME"perlfunc \- Perl builtin functions.IX Xref "function".SH "DESCRIPTION".IX Header "DESCRIPTION"The functions in this section can serve as terms in an expression.They fall into two major categories: list operators and named unaryoperators. These differ in their precedence relationship with afollowing comma. (See the precedence table in perlop.) Listoperators take more than one argument, while unary operators can nevertake more than one argument. Thus, a comma terminates the argument ofa unary operator, but merely separates the arguments of a listoperator. A unary operator generally provides a scalar context to itsargument, while a list operator may provide either scalar or listcontexts for its arguments. If it does both, the scalar arguments willbe first, and the list argument will follow. (Note that there can everbe only one such list argument.) For instance, \fIsplice()\fR has three scalararguments followed by a list, whereas \fIgethostbyname()\fR has four scalararguments..PPIn the syntax descriptions that follow, list operators that expect alist (and provide list context for the elements of the list) are shownwith \s-1LIST\s0 as an argument. Such a list may consist of any combinationof scalar arguments or list values; the list values will be includedin the list as if each individual element were interpolated at thatpoint in the list, forming a longer single-dimensional list value.Commas should separate elements of the \s-1LIST\s0..PPAny function in the list below may be used either with or withoutparentheses around its arguments. (The syntax descriptions omit theparentheses.) If you use the parentheses, the simple (but occasionallysurprising) rule is this: It \fIlooks\fR like a function, therefore it \fIis\fR afunction, and precedence doesn't matter. Otherwise it's a listoperator or unary operator, and precedence does matter. And whitespacebetween the function and left parenthesis doesn't count\*(--so you need tobe careful sometimes:.PP.Vb 5\& print 1+2+4; # Prints 7.\& print(1+2) + 4; # Prints 3.\& print (1+2)+4; # Also prints 3!\& print +(1+2)+4; # Prints 7.\& print ((1+2)+4); # Prints 7..Ve.PPIf you run Perl with the \fB\-w\fR switch it can warn you about this. Forexample, the third line above produces:.PP.Vb 2\& print (...) interpreted as function at \- line 1.\& Useless use of integer addition in void context at \- line 1..Ve.PPA few functions take no arguments at all, and therefore work as neitherunary nor list operators. These include such functions as \f(CW\*(C`time\*(C'\fRand \f(CW\*(C`endpwent\*(C'\fR. For example, \f(CW\*(C`time+86_400\*(C'\fR always means\&\f(CW\*(C`time() + 86_400\*(C'\fR..PPFor functions that can be used in either a scalar or list context,nonabortive failure is generally indicated in a scalar context byreturning the undefined value, and in a list context by returning thenull list..PPRemember the following important rule: There is \fBno rule\fR that relatesthe behavior of an expression in list context to its behavior in scalarcontext, or vice versa. It might do two totally different things.Each operator and function decides which sort of value it would be mostappropriate to return in scalar context. Some operators return thelength of the list that would have been returned in list context. Someoperators return the first value in the list. Some operators return thelast value in the list. Some operators return a count of successfuloperations. In general, they do what you want, unless you wantconsistency..IX Xref "context".PPA named array in scalar context is quite different from what would atfirst glance appear to be a list in scalar context. You can't get a listlike \f(CW\*(C`(1,2,3)\*(C'\fR into being in scalar context, because the compiler knowsthe context at compile time. It would generate the scalar comma operatorthere, not the list construction version of the comma. That means itwas never a list to start with..PPIn general, functions in Perl that serve as wrappers for system callsof the same name (like \fIchown\fR\|(2), \fIfork\fR\|(2), \fIclosedir\fR\|(2), etc.) all returntrue when they succeed and \f(CW\*(C`undef\*(C'\fR otherwise, as is usually mentionedin the descriptions below. This is different from the C interfaces,which return \f(CW\*(C`\-1\*(C'\fR on failure. Exceptions to this rule are \f(CW\*(C`wait\*(C'\fR,\&\f(CW\*(C`waitpid\*(C'\fR, and \f(CW\*(C`syscall\*(C'\fR. System calls also set the special \f(CW$!\fRvariable on failure. Other functions do not, except accidentally..Sh "Perl Functions by Category".IX Xref "function".IX Subsection "Perl Functions by Category"Here are Perl's functions (including things that look likefunctions, like some keywords and named operators)arranged by category. Some functions appear in morethan one place..IP "Functions for SCALARs or strings" 4.IX Xref "scalar string character".IX Item "Functions for SCALARs or strings"\&\f(CW\*(C`chomp\*(C'\fR, \f(CW\*(C`chop\*(C'\fR, \f(CW\*(C`chr\*(C'\fR, \f(CW\*(C`crypt\*(C'\fR, \f(CW\*(C`hex\*(C'\fR, \f(CW\*(C`index\*(C'\fR, \f(CW\*(C`lc\*(C'\fR, \f(CW\*(C`lcfirst\*(C'\fR,\&\f(CW\*(C`length\*(C'\fR, \f(CW\*(C`oct\*(C'\fR, \f(CW\*(C`ord\*(C'\fR, \f(CW\*(C`pack\*(C'\fR, \f(CW\*(C`q//\*(C'\fR, \f(CW\*(C`qq//\*(C'\fR, \f(CW\*(C`reverse\*(C'\fR,\&\f(CW\*(C`rindex\*(C'\fR, \f(CW\*(C`sprintf\*(C'\fR, \f(CW\*(C`substr\*(C'\fR, \f(CW\*(C`tr///\*(C'\fR, \f(CW\*(C`uc\*(C'\fR, \f(CW\*(C`ucfirst\*(C'\fR, \f(CW\*(C`y///\*(C'\fR.IP "Regular expressions and pattern matching" 4.IX Xref "regular expression regex regexp".IX Item "Regular expressions and pattern matching"\&\f(CW\*(C`m//\*(C'\fR, \f(CW\*(C`pos\*(C'\fR, \f(CW\*(C`quotemeta\*(C'\fR, \f(CW\*(C`s///\*(C'\fR, \f(CW\*(C`split\*(C'\fR, \f(CW\*(C`study\*(C'\fR, \f(CW\*(C`qr//\*(C'\fR.IP "Numeric functions" 4.IX Xref "numeric number trigonometric trigonometry".IX Item "Numeric functions"\&\f(CW\*(C`abs\*(C'\fR, \f(CW\*(C`atan2\*(C'\fR, \f(CW\*(C`cos\*(C'\fR, \f(CW\*(C`exp\*(C'\fR, \f(CW\*(C`hex\*(C'\fR, \f(CW\*(C`int\*(C'\fR, \f(CW\*(C`log\*(C'\fR, \f(CW\*(C`oct\*(C'\fR, \f(CW\*(C`rand\*(C'\fR,\&\f(CW\*(C`sin\*(C'\fR, \f(CW\*(C`sqrt\*(C'\fR, \f(CW\*(C`srand\*(C'\fR.ie n .IP "Functions for real @ARRAYs" 4.el .IP "Functions for real \f(CW@ARRAYs\fR" 4.IX Xref "array".IX Item "Functions for real @ARRAYs"\&\f(CW\*(C`pop\*(C'\fR, \f(CW\*(C`push\*(C'\fR, \f(CW\*(C`shift\*(C'\fR, \f(CW\*(C`splice\*(C'\fR, \f(CW\*(C`unshift\*(C'\fR.IP "Functions for list data" 4.IX Xref "list".IX Item "Functions for list data"\&\f(CW\*(C`grep\*(C'\fR, \f(CW\*(C`join\*(C'\fR, \f(CW\*(C`map\*(C'\fR, \f(CW\*(C`qw//\*(C'\fR, \f(CW\*(C`reverse\*(C'\fR, \f(CW\*(C`sort\*(C'\fR, \f(CW\*(C`unpack\*(C'\fR.ie n .IP "Functions for real %HASHes" 4.el .IP "Functions for real \f(CW%HASHes\fR" 4.IX Xref "hash".IX Item "Functions for real %HASHes"\&\f(CW\*(C`delete\*(C'\fR, \f(CW\*(C`each\*(C'\fR, \f(CW\*(C`exists\*(C'\fR, \f(CW\*(C`keys\*(C'\fR, \f(CW\*(C`values\*(C'\fR.IP "Input and output functions" 4.IX Xref "I O input output dbm".IX Item "Input and output functions"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -