Perl 函数大全
-A
-B
-b
-C
-c
-d
-e
-f
-g
-k
-
更年期
l
-M
-O
-o
-p
-R
-r
-S
-s
-T
-t
-
u
-W
-w
-X
-x
-z
abs
accept
Alarm
atan2
bind
Binmode
bless
caller
chdir
chmod
chomp
chop
Chown
chr
chroot
clo
clodir
connect
Continue
cos
crypt
dbmclo
Dbmopen
Defined
delete
die
do
dump
Each
endgrent
endhostent
endnetent
endprotoent
endpwent
endrvent
eof
eval
exec
exists
exit
exp
fcntl
fileno
flock
fork
format
formline
getc
getgrent
getgrgid
getgrname
gethostbyaddr
gethostbyname
gethostent
getlogin
getnetbyaddr
getnetbyname
getnetent
getpeername
getpgrp
getppid
getpriority
getprotobyname
getprotobynumber
getprotoent
getpwent
getpwnam
getpwuid
getrvbyname
getrvbyport
getrvent
伯明翰大学
getsockname
getsockopt
glob
gmtime
goto
grep
hex
import
index
int
ioctl
join
keys
kill
last
lc
lcfirst
length
link
listen
local
localtime
安装合同log
lstat
m//
map
mkdir
msgctl
msgget
msgrcv
msgsnd
my
next
no
oct
open
opendir
ord
pack
package
pipe
pop
pos
pos
printf
push
q/STRING/
qq/STRING/
quotemeta
qw/STRING/
qx/STRING/
rand
read
readdir
readlink
recv
redo
ref
rename
require
ret
return
rever
rewinddir
rindex
rmdir
s///
scalar
ek
ekdir
lect
mctl
mget
mop
nd
tgrent
thostent
tnetent
tpgrp
tpriority
tprotoent
tpwent
trvent
俄料碧玉tsockopt
shift
shmctl
shmget
shmread
shmwrite
shutdown
sin
sleep
socket
socketpair
sort
splice
split
sprintf
sqrt
srand
stat
study
sub
substr
symlink
syscall
麻雀结局sysopen
sysread
system
syswrite
tell
telldir
tie
tied
time
times
tr///
truncate
uc
ucfirst
umask
undef
unlink
unpack
unshift
untie
u
utime
values
vec
wait
waitpid
wantarray
warn
write
y///
--------------------------------------------------------------------------------
Perl has a large number of functions that come as standard with most implementations, and an even wider range of additional modules, each with its own additional functions. This chapter lists all the standard functions alphabetically for reference.
Each function is assigned a category. There
are two main categories; list operators, which can take more than one argument, and named unary operators, which can only take one argument. A condary category is noted in parenthes so you can e, at a glance, the ty
pe of operation the function performs. This is a very rough categorization, as many functions might overlap in any category scheme.
for each function the form of the arguments is listed. If there are multiple forms of calling the function, there will be multiple lines describing each form. The meanings of the arguments are described in the text.
The type of value returned by the function is listed. This is usually specified in more detail in the function description.
Two categories of functions, tho dealing with sockets and tho dealing with System V interprocess communications, are not dealt with in great detail. Both of the categories of function are direct counterparts of UNIX system functions.
The chapter includes
A detailed description of each Perl function, ordered alphabetically.
An example of the functions usage, where applicable.
--------------------------------------------------------------------------------
-A
Syntax
Category named unary operator (file test)
Arguments handle
Arguments filename
Arguments none
Return Value integer (age of file in days since last access relative to $BASETIME)
Definition
The file test operator takes one file handle or filename as an argument. It returns age of file in days since last access relative to $BASETIME. All file test operators can take a special argument underscore, which means that the test is
carried out on the same file handle as the last file test, stat(), or lstat() call. If no argument is supplied, $_ is ud.
Example
print "-A ", -A "/etc/fstab", " ";
--------------------------------------------------------------------------------
-B
Syntax
Category named unary operator (file test)
Arguments handle
Arguments filename
Arguments none
Return Value 1 (true) (fal)
Definition1
The file test operator takes one file handle or filename as an argument. It returns 1 (true) if the file is binary. It returns (fal) if the file is not binary. The first characters of the file are checked to e if the high bit is t and if a suitable number do have the high
bit t the file is assumed to be binary. If the file is empty it is returned as binary. Becau this test involves reading the file itlf, it is best to test to learn if the file exists as a plain file (-f), first. All file test operators can take a special argument underscore, which means that the test is carried out on the same file handle as the last file test, stat(), or lstat() call. If no argument is supplied, $_ is ud.
Example
(-B "/etc/fstab") ? print("-B fstab is binary ") :
print("-B fstab is not binary ");
-
-------------------------------------------------------------------------------
-b
Syntax
Category named unary operator (file test)
Arguments handle
Arguments filename
Arguments none
Return Value 1 (true) (fal)
Definition
The file test operator takes one file handle or filename as an argument. It returns 1 (true) if the file is a block special file (that is, a UNIX /dev device file). It returns (fal) if the file is not a block special file. All file test operators
can take a special argument underscore, which means that the test is carried out on the same file handle as the last file test, stat(), or lstat() call. If no argument is supplied, $_ is ud.
Example
(-b "/dev/hda1") ? print("-b hda1 is block ") :
print("-b hda1 is not block ");
--------------------------------------------------------------------------------
-C
Syntax
Category named unary operator (file test)
Arguments handle
Arguments filename
Arguments none
Return Value integer (age of file in days since last
inode change relative to $BASETIME)
Definition
The file test operator takes one file handle or filename as an argument. It returns age of file in days since last inode change relative to $ BASETIME. All file test operators can take a special argument underscore, which means that the test is carried out on the same file handle as the last file test, stat(), or lstat() call. If no argument is supplied, $_ is ud.
Example
print "-C ", -C "/etc/fstab", " ";
--------------------------------------------------------------------------------
-c
Syntax
Category named unary operator (file test)
Arguments handle
Arguments filename
Arguments none
Return Value 1 (true) (fal)
Definition
The file test operator takes one file handle or filename as a
n argument. It returns 1 (true) if the file is a character special file. It returns (fal) if the file is not a character special file. All file test operators can take a special argument underscore, which means that the test is carried out on the same file handle as the last file test, stat (), or lstat() call. If no argument is supplied, $_ is ud.
Example
(-c "/dev/tty0") ? print("-c tty0 is char ") :
print("-c tty0 is not char ");
--------------------------------------------------------------------------------
-d
Syntax
Category named unary operator (file test)
Arguments handle
Arguments filename
Arguments none
Return Value 1 (true) (fal)
Definition
The file test operator takes one file handle or filename as an argument. It returns 1 (true) if the file is a directory. It returns (fal) if the file is not a directory. All file test operators can take a special argument underscore, which means that the test is carried out on the same file handle as the last file test, stat(), or lstat() call. If no argument is supplied, $_ is ud.
Example
(-d "/") ? print("-d / is dir ") : print("-d / is not dir ");
--------------------------------------------------------------------------------
-e
Syntax
Category named unary operator (file test)
Arguments handle
Arguments filename
Arguments none
Return Value 1 (true) (fal)
Definition
The file test operator takes one file handle or filename as an argument. It returns 1 (true) if file exists. It returns (fal) if the file does not exist. All file test operators can take a special argument underscore, which means that the test is carried out on the same file handle as the last file test, stat(), or lstat() call. If no argument is supplied, $_ is ud.
Example
(-e "/") ? print("-e / exists ") : print("-e / exists ");
--------------------------------------------------------------------------------
-f
Syntax
Category named unary operator (file test)
Arguments handle
Arguments filename
Arguments none
Return Value 1 (true) (fal)
Definition
The file test operator takes one file handle or filename as an argument. It returns 1 (true) if the file is a plain file. It returns (fal) if the file is not a plain file. A plain file is any file that is not a special block device
(-b), a special character device (-c), a directory (-d), a symbolic link (-l), a pipe (-p), a named socket (-S), or a direct link to an I/O terminal (-t). All file
test operators can take a special argument underscore, which means that the test is carried out on the same file handle as the last file test, stat(), or lstat() call. If no argument is supplied, $_ is ud.
Example
(-f "/") ? print("-f / is plain ") : print("-f /
is not plain ");
--------------------------------------------------------------------------------
-g
Syntax
Category named unary operator (file test)
Arguments handle
Arguments filename
Arguments none
Return Value 1 (true) (fal)
Definition
The file test operator takes one file handle or filename as an argument. It returns 1 (true) if the file has the tgid bit t. It returns (fal) if the file does not have the tgid bit t. In UNIX, tgid allows an executable to run as if it was being run by the group, which owns the executable itlf while executing (for example, if a binary is owned by the group wwwstat, and the binary has the getgid bit t, then that binary has access to all files that the wwwstat group can access while the binary is running, even when the binary is run by someone who is not actually a member of the wwwstat group). All file test operators can take a special argument underscore, which means that the test is carried out on the same file handle as the last file test, stat(), or lstat() call. If no argument is supplied, $_ is ud.
Example
(-g "/vmlinuz") ? print("-g /vmlinuz has tgid ") :
print("-g /vmlinuz has not tgid ");
--------------------------------------------------------------------------------
-k
Syntax
Category named unary operator (file test)
Arguments handle
秋瓷炫无法忍受
Arguments filename
Arguments none
Return Value 1 (true) (fal)
Definition
The file test operator takes one file handle or filename as an argument. It returns 1 (true) if the sticky bit is t. It returns (fal) if the sticky bit is not t. In UNIX, the sticky bit can mark an executable file to be held in memory when exited (for example, if the binary ls is marked as sticky, when the first person runs it, it is loaded from disk to memory and executed, but when
the execution finishes, the binary stays in memory so that when the next person runs ls it does not need to be loaded into memory again becau it is already there). This is normally t for frequently ud commands to optimize execution speed. All file test operators can take a special argument underscore, which means that the test is carried out on the same file handle as the last file test, stat(), or lstat() call. If no argument is supplied, $_ is ud.
Example
(-k "/vmlinuz") ? print("-k /vmlinuz is sticky ") :
print("-k /vmlinuz is not sticky ");
--------------------------------------------------------------------------------
-l
Syntax
Category named unary operator (file test)
Arguments handle
Arguments filename
Arguments none
Return Value 1 (true) (fal)
Definition
The file test operator takes one file handle or filename as an argument. It returns 1 (true) if the file is a symbolic link. It returns (fal) if the file is not a symbolic link. All file test operators can take a special argument underscore, which means that the test is carried out on the same file handle as the last file test, stat(), or lstat() call. If no argument is supplied, $_ is ud.
太仓烟雨江南
Example
(-l "/vmlinuz") ? print("-l /vmlinuz is symlink ") :
print("-l /vmlinuz is not symlink ");
--------------------------------------------------------------------------------
-M
Syntax
Category named unary operator (file test)
Arguments handle
Arguments filename
Arguments none
Return Value integer (age of file in days relative to $BASETIME)
圣诞结歌词Definition
The file test operator takes one file handle or filename as an argument. It returns the age of the file in days relative to $BASETIME. All file test operators can take a special argument underscore, which means that the test is carried out on the same file handle as the last file test, stat(), or lstat() call. If no argument is supplied, $_ is ud.
Example
print "-M ", -M "/etc/fstab", " ";
--------------------------------------------------------------------------------
-O
Syntax
Category named unary operator (file test)
Arguments handle
Arguments filename
Arguments none
Return Value 1 (true) (fal)
Definition
The file test operator takes one file handle or filename as an argument. It returns 1 (true) if the file is owned b