perlfunc.pod

来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· POD 代码 · 共 1,629 行 · 第 1/5 页

POD
1,629
字号
each C<use> statement creates a C<require> frame inside an C<eval EXPR>frame.)  $subroutine may also be C<(unknown)> if this particularsubroutine happens to have been deleted from the symbol table.C<$hasargs> is true if a new instance of C<@_> was set up for the frame.C<$hints> and C<$bitmask> contain pragmatic hints that the caller wascompiled with.  The C<$hints> and C<$bitmask> values are subject to changebetween versions of Perl, and are not meant for external use.C<$hinthash> is a reference to a hash containing the value of C<%^H> when thecaller was compiled, or C<undef> if C<%^H> was empty. Do not modify the valuesof this hash, as they are the actual values stored in the optree.Furthermore, when called from within the DB package, caller returns moredetailed information: it sets the list variable C<@DB::args> to be thearguments with which the subroutine was invoked.Be aware that the optimizer might have optimized call frames away beforeC<caller> had a chance to get the information.  That means that C<caller(N)>might not return information about the call frame you expect it do, forC<< N > 1 >>.  In particular, C<@DB::args> might have information from theprevious time C<caller> was called.=item chdir EXPRX<chdir>X<cd>X<directory, change>=item chdir FILEHANDLE=item chdir DIRHANDLE=item chdirChanges the working directory to EXPR, if possible. If EXPR is omitted,changes to the directory specified by C<$ENV{HOME}>, if set; if not,changes to the directory specified by C<$ENV{LOGDIR}>. (Under VMS, thevariable C<$ENV{SYS$LOGIN}> is also checked, and used if it is set.) Ifneither is set, C<chdir> does nothing. It returns true upon success,false otherwise. See the example under C<die>.On systems that support fchdir, you might pass a file handle ordirectory handle as argument.  On systems that don't support fchdir,passing handles produces a fatal error at run time.=item chmod LISTX<chmod> X<permission> X<mode>Changes the permissions of a list of files.  The first element of thelist must be the numerical mode, which should probably be an octalnumber, and which definitely should I<not> be a string of octal digits:C<0644> is okay, C<'0644'> is not.  Returns the number of filessuccessfully changed.  See also L</oct>, if all you have is a string.    $cnt = chmod 0755, 'foo', 'bar';    chmod 0755, @executables;    $mode = '0644'; chmod $mode, 'foo';      # !!! sets mode to                                             # --w----r-T    $mode = '0644'; chmod oct($mode), 'foo'; # this is better    $mode = 0644;   chmod $mode, 'foo';      # this is bestOn systems that support fchmod, you might pass file handles among thefiles.  On systems that don't support fchmod, passing file handlesproduces a fatal error at run time.   The file handles must be passedas globs or references to be recognized.  Barewords are consideredfile names.    open(my $fh, "<", "foo");    my $perm = (stat $fh)[2] & 07777;    chmod($perm | 0600, $fh);You can also import the symbolic C<S_I*> constants from the Fcntlmodule:    use Fcntl ':mode';    chmod S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, @executables;    # This is identical to the chmod 0755 of the above example.=item chomp VARIABLEX<chomp> X<INPUT_RECORD_SEPARATOR> X<$/> X<newline> X<eol>=item chomp( LIST )=item chompThis safer version of L</chop> removes any trailing stringthat corresponds to the current value of C<$/> (also known as$INPUT_RECORD_SEPARATOR in the C<English> module).  It returns the totalnumber of characters removed from all its arguments.  It's often used toremove the newline from the end of an input record when you're worriedthat the final record may be missing its newline.  When in paragraphmode (C<$/ = "">), it removes all trailing newlines from the string.When in slurp mode (C<$/ = undef>) or fixed-length record mode (C<$/> isa reference to an integer or the like, see L<perlvar>) chomp() won'tremove anything.If VARIABLE is omitted, it chomps C<$_>.  Example:    while (<>) {	chomp;	# avoid \n on last field	@array = split(/:/);	# ...    }If VARIABLE is a hash, it chomps the hash's values, but not its keys.You can actually chomp anything that's an lvalue, including an assignment:    chomp($cwd = `pwd`);    chomp($answer = <STDIN>);If you chomp a list, each element is chomped, and the total number ofcharacters removed is returned.Note that parentheses are necessary when you're chomping anythingthat is not a simple variable.  This is because C<chomp $cwd = `pwd`;>is interpreted as C<(chomp $cwd) = `pwd`;>, rather than asC<chomp( $cwd = `pwd` )> which you might expect.  Similarly,C<chomp $a, $b> is interpreted as C<chomp($a), $b> rather thanas C<chomp($a, $b)>.=item chop VARIABLEX<chop>=item chop( LIST )=item chopChops off the last character of a string and returns the characterchopped.  It is much more efficient than C<s/.$//s> because it neitherscans nor copies the string.  If VARIABLE is omitted, chops C<$_>.If VARIABLE is a hash, it chops the hash's values, but not its keys.You can actually chop anything that's an lvalue, including an assignment.If you chop a list, each element is chopped.  Only the value of thelast C<chop> is returned.Note that C<chop> returns the last character.  To return all but the lastcharacter, use C<substr($string, 0, -1)>.See also L</chomp>.=item chown LISTX<chown> X<owner> X<user> X<group>Changes the owner (and group) of a list of files.  The first twoelements of the list must be the I<numeric> uid and gid, in thatorder.  A value of -1 in either position is interpreted by mostsystems to leave that value unchanged.  Returns the number of filessuccessfully changed.    $cnt = chown $uid, $gid, 'foo', 'bar';    chown $uid, $gid, @filenames;On systems that support fchown, you might pass file handles among thefiles.  On systems that don't support fchown, passing file handlesproduces a fatal error at run time.  The file handles must be passedas globs or references to be recognized.  Barewords are consideredfile names.Here's an example that looks up nonnumeric uids in the passwd file:    print "User: ";    chomp($user = <STDIN>);    print "Files: ";    chomp($pattern = <STDIN>);    ($login,$pass,$uid,$gid) = getpwnam($user)	or die "$user not in passwd file";    @ary = glob($pattern);	# expand filenames    chown $uid, $gid, @ary;On most systems, you are not allowed to change the ownership of thefile unless you're the superuser, although you should be able to changethe group to any of your secondary groups.  On insecure systems, theserestrictions may be relaxed, but this is not a portable assumption.On POSIX systems, you can detect this condition this way:    use POSIX qw(sysconf _PC_CHOWN_RESTRICTED);    $can_chown_giveaway = not sysconf(_PC_CHOWN_RESTRICTED);=item chr NUMBERX<chr> X<character> X<ASCII> X<Unicode>=item chrReturns the character represented by that NUMBER in the character set.For example, C<chr(65)> is C<"A"> in either ASCII or Unicode, andchr(0x263a) is a Unicode smiley face.  Negative values give the Unicode replacement character (chr(0xfffd)),except under the L<bytes> pragma, where low eight bits of the value(truncated to an integer) are used.If NUMBER is omitted, uses C<$_>.For the reverse, use L</ord>.Note that characters from 128 to 255 (inclusive) are by defaultinternally not encoded as UTF-8 for backward compatibility reasons.See L<perlunicode> for more about Unicode.=item chroot FILENAMEX<chroot> X<root>=item chrootThis function works like the system call by the same name: it makes thenamed directory the new root directory for all further pathnames thatbegin with a C</> by your process and all its children.  (It doesn'tchange your current working directory, which is unaffected.)  For securityreasons, this call is restricted to the superuser.  If FILENAME isomitted, does a C<chroot> to C<$_>.=item close FILEHANDLEX<close>=item closeCloses the file or pipe associated with the file handle, flushes the IObuffers, and closes the system file descriptor.  Returns true if thoseoperations have succeeded and if no error was reported by any PerlIOlayer.  Closes the currently selected filehandle if the argument isomitted.You don't have to close FILEHANDLE if you are immediately going to doanother C<open> on it, because C<open> will close it for you.  (SeeC<open>.)  However, an explicit C<close> on an input file resets the linecounter (C<$.>), while the implicit close done by C<open> does not.If the file handle came from a piped open, C<close> will additionallyreturn false if one of the other system calls involved fails, or if theprogram exits with non-zero status.  (If the only problem was that theprogram exited non-zero, C<$!> will be set to C<0>.)  Closing a pipealso waits for the process executing on the pipe to complete, in case youwant to look at the output of the pipe afterwards, andimplicitly puts the exit status value of that command into C<$?> andC<${^CHILD_ERROR_NATIVE}>.Prematurely closing the read end of a pipe (i.e. before the processwriting to it at the other end has closed it) will result in aSIGPIPE being delivered to the writer.  If the other end can'thandle that, be sure to read all the data before closing the pipe.Example:    open(OUTPUT, '|sort >foo')  # pipe to sort        or die "Can't start sort: $!";    #...			# print stuff to output    close OUTPUT		# wait for sort to finish        or warn $! ? "Error closing sort pipe: $!"                   : "Exit status $? from sort";    open(INPUT, 'foo')		# get sort's results        or die "Can't open 'foo' for input: $!";FILEHANDLE may be an expression whose value can be used as an indirectfilehandle, usually the real filehandle name.=item closedir DIRHANDLEX<closedir>Closes a directory opened by C<opendir> and returns the success of thatsystem call.=item connect SOCKET,NAMEX<connect>Attempts to connect to a remote socket, just as the connect system calldoes.  Returns true if it succeeded, false otherwise.  NAME should be apacked address of the appropriate type for the socket.  See the examples inL<perlipc/"Sockets: Client/Server Communication">.=item continue BLOCKX<continue>=item continueC<continue> is actually a flow control statement rather than a function.  Ifthere is a C<continue> BLOCK attached to a BLOCK (typically in a C<while> orC<foreach>), it is always executed just before the conditional is about tobe evaluated again, just like the third part of a C<for> loop in C.  Thusit can be used to increment a loop variable, even when the loop has beencontinued via the C<next> statement (which is similar to the C C<continue>statement).C<last>, C<next>, or C<redo> may appear within a C<continue>block.  C<last> and C<redo> will behave as if they had been executed withinthe main block.  So will C<next>, but since it will execute a C<continue>block, it may be more entertaining.    while (EXPR) {	### redo always comes here	do_something;    } continue {	### next always comes here	do_something_else;	# then back the top to re-check EXPR    }    ### last always comes hereOmitting the C<continue> section is semantically equivalent to using anempty one, logically enough.  In that case, C<next> goes directly backto check the condition at the top of the loop.If the "switch" feature is enabled, C<continue> is also afunction that will break out of the current C<when> or C<default>block, and fall through to the next case. See L<feature> andL<perlsyn/"Switch statements"> for more information.=item cos EXPRX<cos> X<cosine> X<acos> X<arccosine>=item cosReturns the cosine of EXPR (expressed in radians).  If EXPR is omitted,takes cosine of C<$_>.For the inverse cosine operation, you may use the C<Math::Trig::acos()>function, or use this relation:    sub acos { atan2( sqrt(1 - $_[0] * $_[0]), $_[0] ) }=item crypt PLAINTEXT,SALT

⌨️ 快捷键说明

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