发信人: saka.bbs@bbs.neu.edu.cn (机器猫), 信区: cnlinux
标  题: perl(10)
发信站: 白山黑水BBS (Tue Apr  1 11:22:53 1997)
转信站: Lilac!ustcnews!ustcnews!sjtunews!neubbs
出  处: conger.neu.edu.cn

--------------22BD6FAE6633
Content-Type: text/plain; charset=us-ascii; name="perlfunc.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="perlfunc.txt"

NAME

perlfunc - Perl builtin functions

---------------------------------------------------------------------------

DESCRIPTION

The functions in this section can serve as terms in an expression. They
fall into two major categories: list operators and named unary operators.
These differ in their precedence relationship with a following comma. (See
the precedence table in the perlop manpage .) List operators take more than
one argument, while unary operators can never take more than one argument.
Thus, a comma terminates the argument of a unary operator, but merely
separates the arguments of a list operator. A unary operator generally
provides a scalar context to its argument, while a list operator may
provide either scalar and list contexts for its arguments. If it does both,
the scalar arguments will be first, and the list argument will follow.
(Note that there can only ever be one list argument.) For instance,
splice() has three scalar arguments followed by a list.

In the syntax descriptions that follow, list operators that expect a list
(and provide list context for the elements of the list) are shown with LIST
as an argument. Such a list may consist of any combination of scalar
arguments or list values; the list values will be included in the list as
if each individual element were interpolated at that point in the list,
forming a longer single-dimensional list value. Elements of the LIST should
be separated by commas.

Any function in the list below may be used either with or without
parentheses around its arguments. (The syntax descriptions omit the
parens.) If you use the parens, the simple (but occasionally surprising)
rule is this: It LOOKS like a function, therefore it IS a function, and
precedence doesn't matter. Otherwise it's a list operator or unary
operator, and precedence does matter. And whitespace between the function
and left parenthesis doesn't count--so you need to be careful sometimes:

    print 1+2+3;        # Prints 6.
    print(1+2) + 3;     # Prints 3.
    print (1+2)+3;      # Also prints 3!
    print +(1+2)+3;     # Prints 6.
    print ((1+2)+3);    # Prints 6.

If you run Perl with the -w switch it can warn you about this. For example,
the third line above produces:

    print (...) interpreted as function at - line 1.
    Useless use of integer addition in void context at - line 1.

For functions that can be used in either a scalar or list context,
non-abortive failure is generally indicated in a scalar context by
returning the undefined value, and in a list context by returning the null
list.

Remember the following rule:

THERE IS NO GENERAL RULE FOR CONVERTING A LIST INTO A SCALAR!

Each operator and function decides which sort of value it would be
most.appropriate to return in a scalar context. Some operators return the
length of the list that would have been returned in a list context. Some
operators return the first value in the list. Some operators return the
last value in the list. Some operators return a count of successful
operations. In general, they do what you want, unless you want consistency.

---------------------------------------------------------------------------

Perl Functions by Category

Here are Perl's functions (including things that look like functions, like
some of the keywords and named operators) arranged by category. Some
functions appear in more than one place.

Functions for SCALARs or strings
     chomp, chop, chr, crypt, hex, index, lc, lcfirst, length, oct, ord,
     pack, q/STRING/, qq/STRING/, reverse, rindex, sprintf, substr, tr///,
     uc, ucfirst, y///

Regular expressions and pattern matching
     m//, pos, quotemeta, s///, split, study

Numeric functions
     abs, atan2, cos, exp, hex, int, log, oct, rand, sin, sqrt, srand

Functions for real @ARRAYs
     pop, push, shift, splice, unshift

Functions for list data
     grep, join, map, qw/STRING/, reverse, sort, unpack

Functions for real %HASHes
     delete, each, exists, keys, values

Input and output functions
     binmode, close, closedir, dbmclose, dbmopen, die, eof, fileno, flock,
     format, getc, print, printf, read, readdir, rewinddir, seek, seekdir,
     select, syscall, sysread, syswrite, tell, telldir, truncate, warn,
     write

Functions for fixed length data or records
     pack, read, syscall, sysread, syswrite, unpack, vec

Functions for filehandles, files, or directories
     -X, chdir, chmod, chown, chroot, fcntl, glob, ioctl, link, lstat,
     mkdir, open, opendir, readlink, rename, rmdir, stat, symlink, umask,
     unlink, utime

Keywords related to the control flow of your perl program
     caller, continue, die, do, dump, eval, exit, goto, last, next, redo,
     return, sub, wantarray

Keywords related to scoping
     caller, import, local, my, package, use

Miscellaneous functions
     defined, dump, eval, formline, local, my, reset, scalar, undef,
     wantarray

Functions for processes and process groups
     alarm, exec, fork, getpgrp, getppid, getpriority, kill, pipe,
     qx/STRING/, setpgrp, setpriority, sleep, system, times, wait, waitpid

Keywords related to perl modules
     do, import, no, package, require, use

Keywords related to classes and object-orientedness
     bless, dbmclose, dbmopen, package, ref, tie, untie, use

Low-level socket functions
     accept, bind, connect, getpeername, getsockname, getsockopt, listen,
     recv, send, setsockopt, shutdown, socket, socketpair

System V interprocess communication functions
     msgctl, msgget, msgrcv, msgsnd, semctl, semget, semop, shmctl, shmget,
     shmread, shmwrite

Fetching user and group info
     endgrent, endhostent, endnetent, endpwent, getgrent, getgrgid,
     getgrnam, getlogin, getpwent, getpwnam, getpwuid, setgrent, setpwent

Fetching network info
     endprotoent, endservent, gethostbyaddr, gethostbyname, gethostent,
     getnetbyaddr, getnetbyname, getnetent, getprotobyname,
     getprotobynumber, getprotoent, getservbyname, getservbyport,
     getservent, sethostent, setnetent, setprotoent, setservent

Time-related functions
     gmtime, localtime, time, times

---------------------------------------------------------------------------

Alphabetical Listing of Perl Functions

See this very long document if you prefer seeing them all at once, or
select from these:

     -X, abs, accept, alarm, atan2, bind, binmode, bless, caller,
     chdir, chmod, chomp, chop, chown, chr, chroot, closedir, close,
     connect, continue, cos, crypt, dbmclose, dbmopen, defined,
     delete, die, do, dump, each, endgrent, endhostent, endnetent,
     endprotoent, endpwent, endservent, eof, eval, exec, exists, exit,
     exp, fcntl, fileno, flock, fork, format, formline, getc,
     getgrent, getgrgid, getgrnam, gethostbyaddr, gethostbyname,
     gethostent, getlogin, getnetbyaddr, getnetbyname, getnetent,
     getpeername, getpgrp, getppid, getpriority, getprotobyname,
     getprotobynumber, getprotoent, getpwent, getpwnam, getpwuid,
     getservbyname, getservbyport, getservent, getsockname,
     getsockopt, glob, gmtime, goto, grep, hex, import, index, int,
     ioctl, join, keys, kill, last, lcfirst, lc, length, link, listen,
     local, localtime, log, lstat, map, m//, mkdir, msgctl, msgget,
     msgrcv, msgsnd, my, next, no, oct, opendir, open, ord, package,
     pack, pipe, pop, pos, printf, print, push, qq/STRING/, q/STRING/,
     quotemeta, qw/STRING/, qx/STRING/, rand, readdir, read, readlink,
     recv, redo, ref, rename, require, reset, return, reverse,
     rewinddir, rindex, rmdir, scalar, seekdir, seek, select, semctl,
     semget, semop, send, setgrent, sethostent, setnetent, setpgrp,
     setpriority, setprotoent, setpwent, setservent, setsockopt,
     shift, shmctl, shmget, shmread, shmwrite, s///, shutdown, sin,
     sleep, socket, socketpair, sort, splice, split, sprintf, sqrt,
     srand, stat, study, sub, substr, symlink, syscall, sysread,
     system, syswrite, telldir, tell, tie, time, times, tr///,
     truncate, ucfirst, uc, umask, undef, unlink, unpack, unshift,
     untie, use, utime, values, vec, wait, waitpid, wantarray, warn,
     write, and y///.

--------------22BD6FAE6633--

--
※ 来源:.白山黑水站 bbs.neu.edu.cn.[FROM: ygh@rose.dlut.edu.cn]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.467毫秒