Perl 简明教程

Perl - Functions References

Here is the list of all the important functions supported by standard Perl.

  1. abs - absolute value function

  2. accept - accept an incoming socket connect

  3. alarm - schedule a SIGALRM

  4. atan2 - arctangent of Y/X in the range -PI to PI

  5. bind - binds an address to a socket

  6. binmode - prepare binary files for I/O

  7. bless - create an object

  8. caller - get context of the current subroutine call

  9. chdir - change your current working directory

  10. chmod - changes the permissions on a list of files

  11. chomp - remove a trailing record separator from a string

  12. chop - remove the last character from a string

  13. chown - change the owership on a list of files

  14. chr - get character this number represents

  15. chroot - make directory new root for path lookups

  16. close - close file (or pipe or socket) handle

  17. closedir - close directory handle

  18. connect - connect to a remote socket

  19. continue - optional trailing block in a while or foreach

  20. cos - cosine function

  21. crypt - one-way passwd-style encryption

  22. dbmclose - breaks binding on a tied dbm file

  23. dbmopen - create binding on a tied dbm file

  24. defined - test whether a value, variable, or function is defined or not

  25. delete - deletes a value from a hash

  26. die - raise an exception or bail out

  27. do - turn a BLOCK into a TERM

  28. dump - create an immediate core dump

  29. each - retrieve the next key/value pair from a hash

  30. endgrent - be done using group file

  31. endhostent - be done using hosts file

  32. endnetent - be done using networks file

  33. endprotoent - be done using protocols file

  34. endpwent - be done using passwd file

  35. endservent - be done using services file

  36. eof - test a filehandle for its end

  37. eval - catch exceptions or compile and run code

  38. exec - abandon this program to run another

  39. exists - test whether a hash key is present

  40. exit - terminate this program

  41. exp - raise I to a power

  42. fcntl - file control system call

  43. fileno - return file descriptor from filehandle

  44. flock - lock an entire file with an advisory lock

  45. fork - create a new process just like this one

  46. format - declare a picture format with use by the write() function

  47. formline - internal function used for formats

  48. getc - get the next character from the filehandle

  49. getgrent - get next group record

  50. getgrgid - get group record given group user ID

  51. getgrnam - get group record given group name

  52. gethostbyaddr - get host record given its address

  53. gethostbyname - get host record given name

  54. gethostent - get next hosts record

  55. getlogin - return who logged in at this tty

  56. getnetbyaddr - get network record given its address

  57. getnetbyname - get networks record given name

  58. getnetent - get next networks record

  59. getpeername - find the other end of a socket connection

  60. getpgrp - get process group

  61. getppid - get parent process ID

  62. getpriority - get current nice value

  63. getprotobyname - get protocol record given name

  64. getprotobynumber - get protocol record numeric protocol

  65. getprotoent - get next protocols record

  66. getpwent - get next passwd record

  67. getpwnam - get passwd record given user login name

  68. getpwuid - get passwd record given user ID

  69. getservbyname - get services record given its name

  70. getservbyport - get services record given numeric port

  71. getservent - get next services record

  72. getsockname - retrieve the sockaddr for a given socket

  73. getsockopt - get socket options on a given socket

  74. glob - expand filenames using wildcards

  75. gmtime - convert UNIX time into record or string using Greenwich time format.

  76. goto - create spaghetti code

  77. grep - locate elements in a list test true against a given criterion

  78. hex - convert a string to a hexadecimal number

  79. import - patch a module’s namespace into your own

  80. index - find a substring within a string

  81. int - get the integer portion of a number

  82. ioctl - system-dependent device control system call

  83. join - join a list into a string using a separator

  84. keys - retrieve list of indices from a hash

  85. kill - send a signal to a process or process group

  86. last - exit a block prematurely

  87. lc - return lower-case version of a string

  88. lcfirst - return a string with just the next letter in lower case

  89. length - return the number of bytes in a string

  90. link - create a hard link in the filesytem

  91. listen - register your socket as a server

  92. local - create a temporary value for a global variable (dynamic scoping)

  93. localtime - convert UNIX time into record or string using local time

  94. lock - get a thread lock on a variable, subroutine, or method

  95. log - retrieve the natural logarithm for a number

  96. lstat - stat a symbolic link

  97. m - match a string with a regular expression pattern

  98. map - apply a change to a list to get back a new list with the changes

  99. mkdir - create a directory

  100. msgctl - SysV IPC message control operations

  101. msgget - get SysV IPC message queue

  102. msgrcv - receive a SysV IPC message from a message queue

  103. msgsnd - send a SysV IPC message to a message queue

  104. my - declare and assign a local variable (lexical scoping)

  105. next - iterate a block prematurely

  106. no - unimport some module symbols or semantics at compile time

  107. oct - convert a string to an octal number

  108. open - open a file, pipe, or descriptor

  109. opendir - open a directory

  110. ord - find a character’s numeric representation

  111. our - declare and assign a package variable (lexical scoping)

  112. pack - convert a list into a binary representation

  113. package - declare a separate global namespace

  114. pipe - open a pair of connected filehandles

  115. pop - remove the last element from an array and return it

  116. pos - find or set the offset for the last/next m//g search

  117. print - output a list to a filehandle

  118. printf - output a formatted list to a filehandle

  119. prototype - get the prototype (if any) of a subroutine

  120. push - append one or more elements to an array

  121. q - singly quote a string

  122. qq - doubly quote a string

  123. qr - Compile pattern

  124. quotemeta - quote regular expression magic characters

  125. qw - quote a list of words

  126. qx - backquote quote a string

  127. rand - retrieve the next pseudorandom number

  128. read - fixed-length buffered input from a filehandle

  129. readdir - get a directory from a directory handle

  130. readline - fetch a record from a file

  131. readlink - determine where a symbolic link is pointing

  132. readpipe - execute a system command and collect standard output

  133. recv - receive a message over a Socket

  134. redo - start this loop iteration over again

  135. ref - find out the type of thing being referenced

  136. rename - change a filename

  137. require - load in external functions from a library at runtime

  138. reset - clear all variables of a given name

  139. return - get out of a function early

  140. reverse - flip a string or a list

  141. rewinddir - reset directory handle

  142. rindex - right-to-left substring search

  143. rmdir - remove a directory

  144. s - replace a pattern with a string

  145. scalar - force a scalar context

  146. seek - reposition file pointer for random-access I/O

  147. seekdir - reposition directory pointer

  148. select - reset default output or do I/O multiplexing

  149. semctl - SysV semaphore control operations

  150. semget - get set of SysV semaphores

  151. semop - SysV semaphore operations

  152. send - send a message over a socket

  153. setgrent - prepare group file for use

  154. sethostent - prepare hosts file for use

  155. setnetent - prepare networks file for use

  156. setpgrp - set the process group of a process

  157. setpriority - set a process’s nice value

  158. setprotoent - prepare protocols file for use

  159. setpwent - prepare passwd file for use

  160. setservent - prepare services file for use

  161. setsockopt - set some socket options

  162. shift - remove the first element of an array, and return it

  163. shmctl - SysV shared memory operations

  164. shmget - get SysV shared memory segment identifier

  165. shmread - read SysV shared memory

  166. shmwrite - write SysV shared memory

  167. shutdown - close down just half of a socket connection

  168. sin - return the sine of a number

  169. sleep - block for some number of seconds

  170. socket - create a socket

  171. socketpair - create a pair of sockets

  172. sort - sort a list of values

  173. splice - add or remove elements anywhere in an array

  174. split - split up a string using a regexp delimiter

  175. sprintf - formatted print into a string

  176. sqrt - square root function

  177. srand - seed the random number generator

  178. stat - get a file’s status information

  179. study - optimize input data for repeated searches

  180. sub - declare a subroutine, possibly anonymously

  181. substr - get or alter a portion of a stirng

  182. symlink - create a symbolic link to a file

  183. syscall - execute an arbitrary system call

  184. sysopen - open a file, pipe, or descriptor

  185. sysread - fixed-length unbuffered input from a filehandle

  186. sysseek - position I/O pointer on handle used with sysread and syswrite

  187. system - run a separate program

  188. syswrite - fixed-length unbuffered output to a filehandle

  189. tell - get current seekpointer on a filehandle

  190. telldir - get current seekpointer on a directory handle

  191. tie - bind a variable to an object class

  192. tied - get a reference to the object underlying a tied variable

  193. time - return number of seconds since 1970

  194. times - return elapsed time for self and child processes

  195. tr - transliterate a string

  196. truncate - shorten a file

  197. uc - return upper-case version of a string

  198. ucfirst - return a string with just the next letter in upper case

  199. umask - set file creation mode mask

  200. undef - remove a variable or function definition

  201. unlink - remove one link to a file

  202. unpack - convert binary structure into normal perl variables

  203. unshift - prepend more elements to the beginning of a list

  204. untie - break a tie binding to a variable

  205. use - load in a module at compile time

  206. utime - set a file’s last access and modify times

  207. values - return a list of the values in a hash

  208. vec - test or set particular bits in a string

  209. wait - wait for any child process to die

  210. waitpid - wait for a particular child process to die

  211. wantarray - get void vs scalar vs list context of current subroutine call

  212. warn - print debugging info

  213. write - print a picture record

  214. -X - a file test (-r, -x, etc)

  215. y - transliterate a string