⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch25.htm

📁 this is a book on pearl , simple example with explanation is given here. it could be beneficial for
💻 HTM
📖 第 1 页 / 共 5 页
字号:
</CENTER><P><BLOCKQUOTE><PRE>$answer = 3;eval(&quot;$answer = ;&quot;);if ($@ eq &quot;&quot;) {    print(&quot;eval() returned success.\n&quot;);}else {    print(&quot;eval() error: $@&quot;);}</PRE></BLOCKQUOTE><H3><A NAME="execLIST">exec (LIST)</A></H3><P><B>Category:</B> Process<BR><B>Return Value:</B> None.<BR><B>Definition:</B> This fuNCtion passes control from the scriptto an external system command. <B>There is no return from thiscall.</B> Note that <TT>system()</TT>calls external commands and does return.<BLOCKQUOTE><PRE>exec(&quot;cat /etc/motd&quot;);</PRE></BLOCKQUOTE><H3><A NAME="existsEXPR">exists (EXPR)</A></H3><P><B>Category:</B> Hash<BR><B>Return Value:</B> SCALAR, true if <TT>EXPR</TT>is an entry in a hash, false if not.<BR><B>Definition:</B> Tests whether a given key value exists in anassociative array.<BLOCKQUOTE><PRE>%test = ( 'One' =&gt; '1', 'Two' =&gt; '2');if (exists($test{'One'})) {    print(&quot;exists() returned success.\n&quot;);}else {    print(&quot;exists() returned an error.\n&quot;);}</PRE></BLOCKQUOTE><H3><A NAME="exitEXPR">exit ([EXPR])</A></H3><P><B>Category:</B> Process<BR><B>Return Value:</B> None.<BR><B>Definition:</B> Evaluates <TT>EXPR</TT>and exits the program with that value as the exit code. The defaultvalue for the exit code is 0 if no argument is supplied. If an<TT>END</TT> block <BR>has been defined, it will be called. Also, object destructorsmay be called before the process truly ends.<BLOCKQUOTE><PRE>exit(16);</PRE></BLOCKQUOTE><H3><A NAME="expEXPR">exp ([EXPR])</A></H3><P><B>Category:</B> Math<BR><B>Return Value:</B> SCALAR, the natural log base (e) to the powerof <TT>EXPR</TT>.<BR><B>Definition:</B> Returns the natural log base (e) to the powerof <TT>EXPR</TT>. If no parameteris specified, <TT>$_</TT> is used.<BLOCKQUOTE><PRE>print &quot;exp() e**1 is &quot;, exp(1), &quot;\n&quot;;</PRE></BLOCKQUOTE><H3><A NAME="fcntlFILEHANDLEFUNCTIONPACKEDFLAGS">fcntl (FILEHANDLE, FUNCTION, PACKED_FLAGS)</A></H3><P><B>Category:</B> File, UNIX<BR><B>Return Value:</B> None.<BR><B>Definition:</B> In Perl 5 use the <TT>fntcl</TT>module. In Perl 4 there should be some mechanism for linking theperl fuNCtions to the system fuNCtions which is usually executedwhen Perl is installed. See the <TT>perlfuNC</TT>man page for more information.<H3><A NAME="filenoFILEHANDLE">fileno (FILEHANDLE)</A></H3><P><B>Category:</B> File<BR><B>Return Value:</B> SCALAR, the file descriptor for <TT>FILEHANDLE</TT>.<BR><B>Definition:</B> Returns the file descriptor given a file handle.File descriptors are useful when using bitmaps for the <TT>select()</TT>fuNCtion.<BLOCKQUOTE><PRE>print(&quot;fileno() &quot;, fileno(FILE), &quot;\n&quot;);</PRE></BLOCKQUOTE><H3><A NAME="flockFILEHANDLEOPERATIONFLAGS">flock (FILEHANDLE, OPERATION_FLAGS)</A></H3><P><B>Category:</B> File<BR><B>Return Value:</B> SCALAR, true if successful, false if not.<BR><B>Definition:</B> Lets you access file locks. You can place anexclusive lock, place a shared lock, or remove locks. You canfind more information about <TT>flock()</TT>in section 2 of the UNIX manual pages.<H3><A NAME="fork">fork ( )</A></H3><P><B>Category:</B> Process UNIX<BR><B>Return Value:</B> SCALAR, the pid of the child process or <TT>undef</TT>is unsuccessful.<BR><B>Definition:</B> Starts a child process. Both child and parentprocesses start executing the line of code immediately followingthe <TT>fork()</TT> call. You canfind more information about <TT>fork()</TT>in section 2 of the UNIX manual pages.<H3><A NAME="formlinePICTURELIST">formline (PICTURE, LIST)</A></H3><P><B>Category:</B> Miscellaneous<BR><B>Return Value:</B> None.<BR><B>Definition:</B> This internal fuNCtion is used by the formatmechanism. It allows direct manipulation of the format processby adding values to the format accumulator (<TT>$^A</TT>).For more information about formats, see <A HREF="ch11.htm" >Chapter 11</A>, &quot;CreatingReports.&quot;<H3><A NAME="getcFILEHANDLE">getc ([FILEHANDLE])</A></H3><P><B>Category:</B> File, Input<BR><B>Return Value:</B> SCALAR, the inputted character. Null if atend of file.<BR><B>Definition:</B> Returns the next character <TT>FILEHANDLE</TT>or <TT>STDIN</TT> if no filehandleis specified.<BLOCKQUOTE><PRE>open(FILE, &quot;/etc/motd&quot;);print &quot;getc() &quot;, getc(FILE), &quot;\n&quot;;close(FILE);</PRE></BLOCKQUOTE><H3><A NAME="getgrent">getgrent ( )</A></H3><P><B>Category:</B> Group, UNIX<BR><B>Return Value: </B>in Scalar Context : Returns the next groupname or the undefined value if no more groups or an error occurred.<BR><B>Return Value in Array Context :</B> (<TT>$name,$passwd, $gid, $members</TT>) or an empty list.<BR><B>Definition:</B> Returns information about groups taken fromthe <TT>/etc/group</TT> system file.If called repeatedly, it will iterate through the entries in the<TT>/etc/group</TT> file.<BLOCKQUOTE><PRE>($name, $pw, $gid, @members) = getgrent();print(&quot;getgrent() Examines /etc/group [$name,$gid] file.\n&quot;);</PRE></BLOCKQUOTE><H3><A NAME="getgrgidGID">getgrgid (GID)</A></H3><P><B>Category:</B> Group, UNIX<BR><B>Return Value: </B>in Scalar Context: The next group name thatbelongs to <TT>GID</TT>.<P><B>Return Value in Array Context:</B> (<TT>$name,$passwd, $gid, $members</TT>) or an empty list.<BR><B>Definition:</B> Returns information about groups taken fromthe <TT>/etc/group</TT> system file.<BLOCKQUOTE><PRE>($grname, $grpw, $gid, @members) = getgrgid(0);print(&quot;getgrgid() Returns group name given GID [$grname]\n&quot;);</PRE></BLOCKQUOTE><H3><A NAME="getgrnameNAME">getgrname (NAME)</A></H3><P><B>Category:</B> Group, UNIX<BR><B>Return Value: </B>in Scalar Context: The next group id thatbelongs to <TT>NAME</TT>.<BR><B>Return Value in Array Context:</B> (<TT>$name,$passwd, $gid, $members</TT>) or an empty list.<BR><B>Definition:</B> Returns information about groups taken fromthe <TT>/etc/group</TT> system file.<BLOCKQUOTE><PRE>($grname, $grpw, $gid, @members) = getgrnam(&quot;root&quot;);print(&quot;getgrnam() Returns group GID given name [$gid]\n&quot;);</PRE></BLOCKQUOTE><H3><A NAME="gethostbyaddrADDRESSAFINIT">gethostbyaddr (ADDRESS, AF_INIT)</A></H3><P><B>Category:</B> Host, Socket<BR><B>Return Value: </B>in Scalar Context: Name of host addressedby <TT>ADDRESS</TT> or undefined ifthe host could not be found.<BR><B>Return Value in Array Context:</B> (<TT>$name</TT>,<TT>$aliases</TT>, <TT>$addrtype</TT>,<TT>$length</TT>, <TT>@addrs</TT>)or an empty list.<BR><B>Definition:</B> Looks in the <TT>/etc/hosts</TT>system file or checks a Domain Name Server for a server with <TT>ADDRESS</TT>.The value for <TT>AF_INIT</TT> isalways 2.<BLOCKQUOTE><PRE>use Socket;$addr = pack('C4', (140,203,7,103));($name, $alias, $addrtype, $length, @addrs) = gethostbyaddr($addr, AF_INET);print(&quot;gethostbyaddr() [$alias].\n&quot;);</PRE></BLOCKQUOTE><H3><A NAME="gethostbynameNAMEPROTOCOL">gethostbyname (NAME, [PROTOCOL])</A></H3><P><B>Category:</B> Host, Socket<BR><B>Return Value: </B>in Scalar Context: Address of the host called<TT>NAME</TT> or undefined if thehost could not be found.<BR><B>Return Value in Array Context:</B> (<TT>$name,$aliases, $addrtype, $length, @addrs</TT>) or an emptylist.<BR><B>Definition:</B> Looks in the <TT>/etc/hosts</TT>system file or checks a Domain Name Server for a server called<TT>NAME</TT>.<BLOCKQUOTE><PRE>($name, $alias, $addrtype, $length, @addrs) = gethostbyname(&quot;lyNCh&quot;);print(&quot;gethostbyname() [$alias].\n&quot;);</PRE></BLOCKQUOTE><H3><A NAME="gethostent">gethostent ( )</A></H3><P><B>Category:</B> Host, UNIX<BR><B>Return Value: </B>in Scalar Context: Name of the next hostin <TT>/etc/hosts</TT>. or the undefinedvalue.<BR><B>Return Value in Array Context:</B> (<TT>$name</TT>,<TT>$aliases</TT>, <TT>$addrtype</TT>,<TT>$length</TT>, <TT>@addrs</TT>)or an empty list.<BR><B>Definition:</B> Looks in the <TT>/etc/hosts</TT>system file.<BLOCKQUOTE><PRE>($name, $alias, $addrtype, $length, @addrs) = gethostent();print(&quot;gethostent() [$alias].\n&quot;);</PRE></BLOCKQUOTE><H3><A NAME="getlogin">getlogin ( )</A></H3><P><B>Category:</B> Process, UNIX<BR><B>Return Value:</B> SCALAR, the name of the current login.<BR><B>Definition:</B> Gets the current login name from the <TT>/etc/utmp</TT>system file. Use <TT>getpwuid()</TT>formore information on the login because the information stored in<TT>/etc/utmp</TT> is limited.<BLOCKQUOTE><PRE>print (&quot;getlogin() &quot;, getlogin(), &quot;\n&quot;);</PRE></BLOCKQUOTE><H3><A NAME="getnetbyaddrADDRESSADDRTYPE">getnetbyaddr (ADDRESS, ADDR_TYPE)</A></H3><P><B>Category:</B> Network<BR><B>Return Value: </B>in Scalar Context: The network name thathas an address of <TT>ADDRESS</TT>or undefined.<BR><B>Return Value in Array Context:</B> (<TT>$name</TT>,<TT>$aliases</TT>, <TT>$addrtype</TT>,<TT>$net</TT>) or an empty list.<BR><B>Definition:</B> Looks for the network information in the <TT>/etc/networks</TT>system file.<BLOCKQUOTE><PRE>($addrtype) = (getnetent())[2];($name, $alias, $addrtype, $net) = getnetbyaddr($net, $addrtype);print(&quot;getnetbyaddr() Reads /etc/networks [$name]\n&quot;);</PRE></BLOCKQUOTE><H3><A NAME="getnetbynameNAME">getnetbyname (NAME)</A></H3><P><B>Category:</B> Network<BR><B>Return Value: </B>in Scalar Context: The network address of<TT>NAME</TT> or undefined.<BR><B>Return Value in Array Context:</B> (<TT>$name</TT>,<TT>$aliases</TT>, <TT>$addrtype</TT>,<TT>$net</TT>) or an empty list.<BR><B>Definition:</B> Looks for the network information in the <TT>/etc/networks</TT>system file.<BLOCKQUOTE><PRE>($name, $alias, $addrtype, $net) = getnetbyname(&quot;localnet&quot;);print(&quot;getnetbyname() Reads /etc/networks [$name]\n&quot;);</PRE></BLOCKQUOTE><H3><A NAME="getnetent">getnetent ( )</A></H3><P><B>Category:</B> Network<BR><B>Return Value in Scalar Context:</B> The next network name in<TT>/etc/networks</TT> or undefined.<BR><B>Return Value in Array Context:</B> (<TT>$name</TT>,<TT>$aliases</TT>, <TT>$addrtype</TT>,<TT>$net</TT>) or an empty list.<BR><B>Definition:</B> When called repeatedly, it iterates over theinformation in the <TT>/etc/networks</TT>system file.<BLOCKQUOTE><PRE>($name, $alias, $addrtype, $net) = getnetent();print(&quot;getnetent() Reads /etc/networks [$name, $addrtype]\n&quot;);</PRE></BLOCKQUOTE><H3><A NAME="getpeernameSOCKET">getpeername (SOCKET)</A></H3><P><B>Category:</B> Sockets<BR><B>Return Value:</B> SCALAR, the address of the remote side ofa socket connection represented by <TT>SOCKET</TT>.<BR><B>Definition:</B> Gets the packed address of the remote sideof a socket. The address can then be used with the <TT>unpack()</TT>fuNCtion to retrieve the protocol family, port and ip addressvalues.<BLOCKQUOTE><PRE>$sockaddr = 'S n a4 x8';$packedRemoteAddr = getpeername(S);($family, $port, $remoteAddr) = unpack($sockaddr,$packedRemoteAddr);</PRE></BLOCKQUOTE><H3><A NAME="getpgrpPID">getpgrp (PID)</A></H3><P><B>Category:</B> Groups, Process, UNIX<BR><B>Return Value:</B> SCALAR, the current process group for <TT>PID</TT>.If <TT>PID</TT> is not specified or0 is used, the current group of the current process is returned.<BR><B>Definition:</B> Finds the current process group for a given<TT>pid</TT>.<BLOCKQUOTE><PRE>print(&quot;getpgrp() &quot;, getpgrp(0), &quot;\n&quot;);</PRE></BLOCKQUOTE><H3><A NAME="getppid">getppid ( )</A></H3><P><B>Category:</B> Process, UNIX<BR><B>Return Value:</B> SCALAR, the pid of the parent process.<BR><B>Definition:</B> Finds the pid of the parent process.<BLOCKQUOTE><PRE>print(&quot;getppid() &quot;, getppid(), &quot;\n&quot;);</PRE></BLOCKQUOTE><H3><A NAME="getpriorityWHICHWHO">getpriority (WHICH, WHO)</A></H3><P><B>Category:</B> Process, UNIX<BR><B>Return Value:</B> SCALAR, the current priority associated withthe parameters.<BR><B>Definition:</B> Returns the current priority of <TT>WHO</TT>(the pid, group pid, uid, or 0 for the current process). The <TT>WHICH</TT>parameter can one of <TT>PRIO_PROCESS</TT>(0), <TT>PRIO_PGGRP</TT> (1), <TT>PRIO_USER</TT>(2).<BLOCKQUOTE><PRE>print(&quot;getpriority() &quot;, getpriority(0, 0), &quot;\n&quot;);</PRE></BLOCKQUOTE><H3><A NAME="getprotobynameNAME">getprotobyname (NAME)</A></H3><P><B>Category:</B> Protocols, UNIX<BR><B>Return Value: </B>in Scalar Context: The protocol number assignedto <TT>NAME</TT>.<BR><B>Return Value in Array Context:</B> (<TT>$name</TT>,<TT>$aliases</TT>, <TT>$proto</TT>)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -