📄 appa.htm
字号:
<HTML>
<HEAD>
<TITLE>appendix A-- Perl 5 Function and Variable Reference</TITLE>
<META NAME="GENERATOR" CONTENT="Mozilla/3.0b5aGold (WinNT; I) [Netscape]">
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#CE2910">
<H1><FONT COLOR=#FF0000>appendix A</FONT></H1>
<H1><B><FONT SIZE=5 COLOR=#FF0000>Perl 5 Function and Variable Reference</FONT></B>
</H1>
<P>
<HR WIDTH="100%"></P>
<P>
This appendix presents a brief alphabetic synopsis of all available
Perl functions to enable you to quickly look up the functions'
syntax. This appendix is not intended to provide a complete, exhaustive
reference. For a complete documentation set on Perl 5, you can
visit the CPAN site described in the following note.<P>
<CENTER>
<TABLE BORDERCOLOR=#000000 BORDER=1 WIDTH=80%>
<TR VALIGN=TOP><TD WIDTH=573><B>Note</B></TD></TR>
<TR VALIGN=TOP><TD WIDTH=573>
<BLOCKQUOTE>
You can obtain the complete reference manual for Perl from the CPAN Web sites. The most comprehensive set is the 950KB zipped file available at the following URL:</BLOCKQUOTE>
<BLOCKQUOTE>
<TT><FONT FACE="Courier">www.perl.com/CPAN/doc/manual/text/PerlDoc-5.002b1g-txt.tar.gz</FONT></TT>
</BLOCKQUOTE>
<BLOCKQUOTE>
Once unzipped and untarred, the archive expands to several reference documents. These online documents will provide a far more comprehensive, up-to-date reference material on Perl than is provided in this appendix.</BLOCKQUOTE>
</TD></TR>
</TABLE></CENTER>
<P>
<P>
Here are a few points to note when using this appendix:
<UL>
<LI><FONT COLOR=#000000>Parameters to functions can be specified
either with or without parentheses. For example, the following
two statements are equivalent:<BR>
</FONT><TT><FONT FACE="Courier">alarm 3;<BR>
alarm (3);<BR>
</FONT></TT><FONT COLOR=#000000>The placeholders for variables
are shown in italics or all uppercase. A placeholder is a generic
term for which you are to substitute specific information. Where
all uppercase characters are used, the placeholder implies a handle
to a system resource such as a file, directory, pipe, or socket.
For example, when the context is relevant, the word SOCKET implies
a handle to a socket.</FONT>
<LI><FONT COLOR=#000000>All optional parameters (and related semicolons)
are listed in square brackets. Do not include the square brackets
in your code for this syntax. For example, the </FONT><TT><FONT FACE="Courier">bless</FONT></TT>
function can take one or two parameters, so it's listed as follows:
<BR>
<TT><FONT FACE="Courier">bless REFEREncE[,CLASS]<BR>
</FONT></TT>which means that you can make these two calls:<BR>
<TT><FONT FACE="Courier">bless $this,<BR>
bless $this,myClass<BR>
</FONT></TT>but not this call:<BR>
<TT><FONT FACE="Courier">bless $this,[myClass]</FONT></TT>
<LI><FONT COLOR=#000000>When there is more than one type of parameter
as an argument or a list of arguments to a function, all such
types of syntax are listed.</FONT>
<LI><FONT COLOR=#000000>A code block refers to a set of Perl statements
within a pair of curly braces. The code block includes the surrounding
curly braces if there is more than one statement in it. For example,
the </FONT><TT><FONT FACE="Courier">do</FONT></TT> command is
really written as follows:<BR>
<BR>
<TT><FONT FACE="Courier">do {<BR>
<I>something here<BR>
something there<BR>
more code<BR>
statement...<BR>
</I>}</FONT></TT>
<LI>The code block above is shown in italics for the <TT><FONT FACE="Courier">do</FONT></TT>
loop.
</UL>
<H4><TT><FONT FACE="Courier">-X [FILEHANDLE or Expression]</FONT></TT>
</H4>
<P>
The <TT><FONT FACE="Courier">-X</FONT></TT> command is a unary
file test operator. <TT><FONT FACE="Courier">X</FONT></TT> can
take one of the following values:<P>
<CENTER>
<TABLE BORDER=1>
<TR VALIGN=TOP><TD WIDTH=79><CENTER><TT><FONT FACE="Courier">-A</FONT></TT></CENTER>
</TD><TD WIDTH=264>Same for access time.</TD></TR>
<TR VALIGN=TOP><TD WIDTH=79><CENTER><TT><FONT FACE="Courier">-B</FONT></TT></CENTER>
</TD><TD WIDTH=264>File is a binary file (opposite of <TT><FONT FACE="Courier">-T</FONT></TT>).
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=79><CENTER><TT><FONT FACE="Courier">-b</FONT></TT></CENTER>
</TD><TD WIDTH=264>File is a block special file.</TD></TR>
<TR VALIGN=TOP><TD WIDTH=79><CENTER><TT><FONT FACE="Courier">-c</FONT></TT></CENTER>
</TD><TD WIDTH=264>File is a character special file.</TD></TR>
<TR VALIGN=TOP><TD WIDTH=79><CENTER><TT><FONT FACE="Courier">-C</FONT></TT></CENTER>
</TD><TD WIDTH=264>Same for <TT><FONT FACE="Courier">inode</FONT></TT> change time.
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=79><CENTER><TT><FONT FACE="Courier">-d</FONT></TT></CENTER>
</TD><TD WIDTH=264>File is a directory.</TD></TR>
<TR VALIGN=TOP><TD WIDTH=79><CENTER><TT><FONT FACE="Courier">-e</FONT></TT></CENTER>
</TD><TD WIDTH=264>File exists.</TD></TR>
<TR VALIGN=TOP><TD WIDTH=79><CENTER><TT><FONT FACE="Courier">-f</FONT></TT></CENTER>
</TD><TD WIDTH=264>File is a plain file.</TD></TR>
<TR VALIGN=TOP><TD WIDTH=79><CENTER><TT><FONT FACE="Courier">-g</FONT></TT></CENTER>
</TD><TD WIDTH=264>File has <TT><FONT FACE="Courier">setgid</FONT></TT> bit set.
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=79><CENTER><TT><FONT FACE="Courier">-k</FONT></TT></CENTER>
</TD><TD WIDTH=264>File has <TT><FONT FACE="Courier">sticky</FONT></TT> bit set.
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=79><CENTER><TT><FONT FACE="Courier">-l</FONT></TT></CENTER>
</TD><TD WIDTH=264>File is a symbolic link.</TD></TR>
<TR VALIGN=TOP><TD WIDTH=79><CENTER><TT><FONT FACE="Courier">-M</FONT></TT></CENTER>
</TD><TD WIDTH=264>Age of file in days when script started.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH=79><CENTER><TT><FONT FACE="Courier">-o</FONT></TT></CENTER>
</TD><TD WIDTH=264>File is owned by effective <TT><FONT FACE="Courier">uid</FONT></TT>.
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=79><CENTER><TT><FONT FACE="Courier">-O</FONT></TT></CENTER>
</TD><TD WIDTH=264>File is owned by real <TT><FONT FACE="Courier">uid</FONT></TT>.
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=79><CENTER><TT><FONT FACE="Courier">-p</FONT></TT></CENTER>
</TD><TD WIDTH=264>File is a named pipe (FIFO).</TD></TR>
<TR VALIGN=TOP><TD WIDTH=79><CENTER><TT><FONT FACE="Courier">-r</FONT></TT></CENTER>
</TD><TD WIDTH=264>File is readable by effective <TT><FONT FACE="Courier">uid</FONT></TT>/<TT><FONT FACE="Courier">gid</FONT></TT>.
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=79><CENTER><TT><FONT FACE="Courier">-R</FONT></TT></CENTER>
</TD><TD WIDTH=264>File is readable by real <TT><FONT FACE="Courier">uid</FONT></TT>/<TT><FONT FACE="Courier">gid</FONT></TT>.
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=79><CENTER><TT><FONT FACE="Courier">-s</FONT></TT></CENTER>
</TD><TD WIDTH=264>File has non-zero size (returns size).</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH=79><CENTER><TT><FONT FACE="Courier">-S</FONT></TT></CENTER>
</TD><TD WIDTH=264>File is a socket.</TD></TR>
<TR VALIGN=TOP><TD WIDTH=79><CENTER><TT><FONT FACE="Courier">-t</FONT></TT></CENTER>
</TD><TD WIDTH=264>File handle is opened to a <TT><FONT FACE="Courier">tty</FONT></TT>.
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=79><CENTER><TT><FONT FACE="Courier">-T</FONT></TT></CENTER>
</TD><TD WIDTH=264>File is a text file.</TD></TR>
<TR VALIGN=TOP><TD WIDTH=79><CENTER><TT><FONT FACE="Courier">-u</FONT></TT></CENTER>
</TD><TD WIDTH=264>File has <TT><FONT FACE="Courier">setuid</FONT></TT> bit set.
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=79><CENTER><TT><FONT FACE="Courier">-w</FONT></TT></CENTER>
</TD><TD WIDTH=264>File is writable by effective <TT><FONT FACE="Courier">uid</FONT></TT>/<TT><FONT FACE="Courier">gid</FONT></TT>.
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=79><CENTER><TT><FONT FACE="Courier">-W</FONT></TT></CENTER>
</TD><TD WIDTH=264>File is writable by real <TT><FONT FACE="Courier">uid</FONT></TT>/<TT><FONT FACE="Courier">gid</FONT></TT>.
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=79><CENTER><TT><FONT FACE="Courier">-x</FONT></TT></CENTER>
</TD><TD WIDTH=264>File is executable by effective <TT><FONT FACE="Courier">uid</FONT></TT>/<TT><FONT FACE="Courier">gid</FONT></TT>.
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=79><CENTER><TT><FONT FACE="Courier">-X</FONT></TT></CENTER>
</TD><TD WIDTH=264>File is executable by real <TT><FONT FACE="Courier">uid</FONT></TT>/<TT><FONT FACE="Courier">gid</FONT></TT>.
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=79><CENTER><TT><FONT FACE="Courier">-z</FONT></TT></CENTER>
</TD><TD WIDTH=264>File has zero byte size.</TD></TR>
</TABLE></CENTER>
<P>
<P>
The <TT><FONT FACE="Courier">-X</FONT></TT> operator takes one
argument: a filename or a file handle. Then it applies a test
with the associated file for what's requested. It uses <TT><FONT FACE="Courier">$_</FONT></TT>
if no argument is given. The exception to this rule is the <TT><FONT FACE="Courier">-t</FONT></TT>
test, which defaults to using <TT><FONT FACE="Courier">STDIN</FONT></TT>.
The function returns <TT><FONT FACE="Courier">1</FONT></TT> if
the tested condition is <TT><FONT FACE="Courier">true</FONT></TT>;
otherwise, it returns <TT><FONT FACE="Courier">false</FONT></TT>.
The precedence for this operator is the same as any other named
unary operator. The arguments into this function may be parenthesized
like any other unary operator.
<P>
The permission operators (<TT><FONT FACE="Courier">-r</FONT></TT>,
<TT><FONT FACE="Courier">-R</FONT></TT>, <TT><FONT FACE="Courier">-w</FONT></TT>
, <TT><FONT FACE="Courier">-W</FONT></TT>, <TT><FONT FACE="Courier">-x</FONT></TT>,
and <TT><FONT FACE="Courier">-X</FONT></TT> ) test the <TT><FONT FACE="Courier">umask</FONT></TT>
file permissions and those of the calling program's <TT><FONT FACE="Courier">uid</FONT></TT>s
and <TT><FONT FACE="Courier">gid</FONT></TT>s. Other reasons why
you can't actually read, write, or execute the file are ignored.
When tested while a program is running as <TT><FONT FACE="Courier">root</FONT></TT>,
the read/write flags will always return <TT><FONT FACE="Courier">1</FONT></TT>
as the test. The values from the <TT><FONT FACE="Courier">-x</FONT></TT>
and <TT><FONT FACE="Courier">-X</FONT></TT> return <TT><FONT FACE="Courier">1</FONT></TT>
only if any execute bit is set. It's probably better to use the
<TT><FONT FACE="Courier">stat()</FONT></TT> function instead to
figure out the mode of the file.
<P>
The <TT><FONT FACE="Courier">-T</FONT></TT> and <TT><FONT FACE="Courier">-B</FONT></TT>
switches determine the type of file by looking at the first few
blocks of the file. If there are non-ASCII characters in there,
the file is assumed to be binary. Control codes generally have
the highest bit set, which is what Perl looks for. Also, any file
containing <TT><FONT FACE="Courier">null</FONT></TT> in the first
block is considered a binary file.
<P>
If <TT><FONT FACE="Courier">-T</FONT></TT> or <TT><FONT FACE="Courier">-B</FONT></TT>
is used on a file handle, the current input buffer is examined
rather than the first block. Both <TT><FONT FACE="Courier">-T</FONT></TT>
and <TT><FONT FACE="Courier">-B</FONT></TT> return <TT><FONT FACE="Courier">TRUE</FONT></TT>
on a <TT><FONT FACE="Courier">null</FONT></TT> file or from a
file pointer at EOF when testing a file handle. To be able to
perform a <TT><FONT FACE="Courier">-T</FONT></TT> or <TT><FONT FACE="Courier">-B</FONT></TT>
test on a file, you have to be able to read it. To test for readability,
use the <TT><FONT FACE="Courier">-f</FONT></TT> option along with
the <TT><FONT FACE="Courier">-T</FONT></TT> or <TT><FONT FACE="Courier">-B</FONT></TT>
flag: <TT><FONT FACE="Courier">-f $file && -T $file</FONT></TT>.
Like the <TT><FONT FACE="Courier">stat()</FONT></TT> operator,
the special handle referred by the underscore (<TT><FONT FACE="Courier">_</FONT></TT>)
is the last file handle used. This shortcut does not work with
<TT><FONT FACE="Courier">-t</FONT></TT>.
<H4><TT><FONT FACE="Courier">abs value</FONT></TT></H4>
<P>
The absolute value of its argument. Non-numeric arguments return
a value of <TT><FONT FACE="Courier">0</FONT></TT>.
<H4><TT><FONT FACE="Courier">accept newSocket, oldSocket</FONT></TT>
</H4>
<P>
This call is used to accept an incoming packet. The return value
is the packed address if successful, or <TT><FONT FACE="Courier">FALSE</FONT></TT>
if not successful. The underlying call is the same as the <TT><FONT FACE="Courier">accept()</FONT></TT>
system call in UNIX. <A HREF="ch12.htm" tppabs="http://www.mcp.com/815097600/0-672/0-672-30891-6/ch12.htm" >See Chapter 12</A>, "Using
Sockets."
<H4><TT><FONT FACE="Courier">alarm seconds</FONT></TT></H4>
<P>
Sets up a timer to send the <TT><FONT FACE="Courier">SIGALRM</FONT></TT>
signal to a process after the approximate number of seconds in
the argument have passed. Each call to <TT><FONT FACE="Courier">alarm</FONT></TT>
resets any previous timer. A value of <TT><FONT FACE="Courier">0</FONT></TT>
for the timer disables any previous timer. The returned value
is the number of seconds on the previous timer. Don't use the
<TT><FONT FACE="Courier">sleep()</FONT></TT> call with the <TT><FONT FACE="Courier">alarm</FONT></TT>
call in the same code block because they share the same internal
Perl variables in two different ways.
<H4><TT><FONT FACE="Courier">atan2 Y,X</FONT></TT></H4>
<P>
Returns the arctangent of <TT><FONT FACE="Courier">Y/X</FONT></TT>.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -