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

📄 perlfunc.1

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 1
📖 第 1 页 / 共 5 页
字号:
.PD 0.IP "chdir \s-1FILEHANDLE\s0" 8.IX Item "chdir FILEHANDLE".IP "chdir \s-1DIRHANDLE\s0" 8.IX Item "chdir DIRHANDLE".IP "chdir" 8.IX Item "chdir".PDChanges the working directory to \s-1EXPR\s0, if possible. If \s-1EXPR\s0 is omitted,changes to the directory specified by \f(CW$ENV{HOME}\fR, if set; if not,changes to the directory specified by \f(CW$ENV{LOGDIR}\fR. (Under \s-1VMS\s0, thevariable \f(CW$ENV{SYS$LOGIN}\fR is also checked, and used if it is set.) Ifneither is set, \f(CW\*(C`chdir\*(C'\fR does nothing. It returns true upon success,false otherwise. See the example under \f(CW\*(C`die\*(C'\fR..SpOn 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..IP "chmod \s-1LIST\s0" 8.IX Xref "chmod permission mode".IX Item "chmod LIST"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 \fInot\fR be a string of octal digits:\&\f(CW0644\fR is okay, \f(CW\*(Aq0644\*(Aq\fR is not.  Returns the number of filessuccessfully changed.  See also \*(L"oct\*(R", if all you have is a string..Sp.Vb 6\&    $cnt = chmod 0755, \*(Aqfoo\*(Aq, \*(Aqbar\*(Aq;\&    chmod 0755, @executables;\&    $mode = \*(Aq0644\*(Aq; chmod $mode, \*(Aqfoo\*(Aq;      # !!! sets mode to\&                                             # \-\-w\-\-\-\-r\-T\&    $mode = \*(Aq0644\*(Aq; chmod oct($mode), \*(Aqfoo\*(Aq; # this is better\&    $mode = 0644;   chmod $mode, \*(Aqfoo\*(Aq;      # this is best.Ve.SpOn 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..Sp.Vb 3\&    open(my $fh, "<", "foo");\&    my $perm = (stat $fh)[2] & 07777;\&    chmod($perm | 0600, $fh);.Ve.SpYou can also import the symbolic \f(CW\*(C`S_I*\*(C'\fR constants from the Fcntlmodule:.Sp.Vb 1\&    use Fcntl \*(Aq:mode\*(Aq;\&\&    chmod S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, @executables;\&    # This is identical to the chmod 0755 of the above example..Ve.IP "chomp \s-1VARIABLE\s0" 8.IX Xref "chomp INPUT_RECORD_SEPARATOR $ newline eol".IX Item "chomp VARIABLE".PD 0.IP "chomp( \s-1LIST\s0 )" 8.IX Item "chomp( LIST )".IP "chomp" 8.IX Item "chomp".PDThis safer version of \*(L"chop\*(R" removes any trailing stringthat corresponds to the current value of \f(CW$/\fR (also known as\&\f(CW$INPUT_RECORD_SEPARATOR\fR in the \f(CW\*(C`English\*(C'\fR 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 (\f(CW\*(C`$/ = ""\*(C'\fR), it removes all trailing newlines from the string.When in slurp mode (\f(CW\*(C`$/ = undef\*(C'\fR) or fixed-length record mode (\f(CW$/\fR isa reference to an integer or the like, see perlvar) \fIchomp()\fR won'tremove anything.If \s-1VARIABLE\s0 is omitted, it chomps \f(CW$_\fR.  Example:.Sp.Vb 5\&    while (<>) {\&        chomp;  # avoid \en on last field\&        @array = split(/:/);\&        # ...\&    }.Ve.SpIf \s-1VARIABLE\s0 is a hash, it chomps the hash's values, but not its keys..SpYou can actually chomp anything that's an lvalue, including an assignment:.Sp.Vb 2\&    chomp($cwd = \`pwd\`);\&    chomp($answer = <STDIN>);.Ve.SpIf you chomp a list, each element is chomped, and the total number ofcharacters removed is returned..SpNote that parentheses are necessary when you're chomping anythingthat is not a simple variable.  This is because \f(CW\*(C`chomp $cwd = \`pwd\`;\*(C'\fRis interpreted as \f(CW\*(C`(chomp $cwd) = \`pwd\`;\*(C'\fR, rather than as\&\f(CW\*(C`chomp( $cwd = \`pwd\` )\*(C'\fR which you might expect.  Similarly,\&\f(CW\*(C`chomp $a, $b\*(C'\fR is interpreted as \f(CW\*(C`chomp($a), $b\*(C'\fR rather thanas \f(CW\*(C`chomp($a, $b)\*(C'\fR..IP "chop \s-1VARIABLE\s0" 8.IX Xref "chop".IX Item "chop VARIABLE".PD 0.IP "chop( \s-1LIST\s0 )" 8.IX Item "chop( LIST )".IP "chop" 8.IX Item "chop".PDChops off the last character of a string and returns the characterchopped.  It is much more efficient than \f(CW\*(C`s/.$//s\*(C'\fR because it neitherscans nor copies the string.  If \s-1VARIABLE\s0 is omitted, chops \f(CW$_\fR.If \s-1VARIABLE\s0 is a hash, it chops the hash's values, but not its keys..SpYou can actually chop anything that's an lvalue, including an assignment..SpIf you chop a list, each element is chopped.  Only the value of thelast \f(CW\*(C`chop\*(C'\fR is returned..SpNote that \f(CW\*(C`chop\*(C'\fR returns the last character.  To return all but the lastcharacter, use \f(CW\*(C`substr($string, 0, \-1)\*(C'\fR..SpSee also \*(L"chomp\*(R"..IP "chown \s-1LIST\s0" 8.IX Xref "chown owner user group".IX Item "chown LIST"Changes the owner (and group) of a list of files.  The first twoelements of the list must be the \fInumeric\fR 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..Sp.Vb 2\&    $cnt = chown $uid, $gid, \*(Aqfoo\*(Aq, \*(Aqbar\*(Aq;\&    chown $uid, $gid, @filenames;.Ve.SpOn 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..SpHere's an example that looks up nonnumeric uids in the passwd file:.Sp.Vb 4\&    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;.Ve.SpOn 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 \s-1POSIX\s0 systems, you can detect this condition this way:.Sp.Vb 2\&    use POSIX qw(sysconf _PC_CHOWN_RESTRICTED);\&    $can_chown_giveaway = not sysconf(_PC_CHOWN_RESTRICTED);.Ve.IP "chr \s-1NUMBER\s0" 8.IX Xref "chr character ASCII Unicode".IX Item "chr NUMBER".PD 0.IP "chr" 8.IX Item "chr".PDReturns the character represented by that \s-1NUMBER\s0 in the character set.For example, \f(CW\*(C`chr(65)\*(C'\fR is \f(CW"A"\fR in either \s-1ASCII\s0 or Unicode, andchr(0x263a) is a Unicode smiley face..SpNegative values give the Unicode replacement character (\fIchr\fR\|(0xfffd)),except under the bytes pragma, where low eight bits of the value(truncated to an integer) are used..SpIf \s-1NUMBER\s0 is omitted, uses \f(CW$_\fR..SpFor the reverse, use \*(L"ord\*(R"..SpNote that characters from 128 to 255 (inclusive) are by defaultinternally not encoded as \s-1UTF\-8\s0 for backward compatibility reasons..SpSee perlunicode for more about Unicode..IP "chroot \s-1FILENAME\s0" 8.IX Xref "chroot root".IX Item "chroot FILENAME".PD 0.IP "chroot" 8.IX Item "chroot".PDThis 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 \f(CW\*(C`/\*(C'\fR 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 \s-1FILENAME\s0 isomitted, does a \f(CW\*(C`chroot\*(C'\fR to \f(CW$_\fR..IP "close \s-1FILEHANDLE\s0" 8.IX Xref "close".IX Item "close FILEHANDLE".PD 0.IP "close" 8.IX Item "close".PDCloses the file or pipe associated with the file handle, flushes the \s-1IO\s0buffers, 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..SpYou don't have to close \s-1FILEHANDLE\s0 if you are immediately going to doanother \f(CW\*(C`open\*(C'\fR on it, because \f(CW\*(C`open\*(C'\fR will close it for you.  (See\&\f(CW\*(C`open\*(C'\fR.)  However, an explicit \f(CW\*(C`close\*(C'\fR on an input file resets the linecounter (\f(CW$.\fR), while the implicit close done by \f(CW\*(C`open\*(C'\fR does not..SpIf the file handle came from a piped open, \f(CW\*(C`close\*(C'\fR 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, \f(CW$!\fR will be set to \f(CW0\fR.)  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 \f(CW$?\fR and\&\f(CW\*(C`${^CHILD_ERROR_NATIVE}\*(C'\fR..SpPrematurely closing the read end of a pipe (i.e. before the processwriting to it at the other end has closed it) will result in a\&\s-1SIGPIPE\s0 being delivered to the writer.  If the other end can'thandle that, be sure to read all the data before closing the pipe..SpExample:.Sp.Vb 8\&    open(OUTPUT, \*(Aq|sort >foo\*(Aq)  # pipe to sort\&        or die "Can\*(Aqt 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, \*(Aqfoo\*(Aq)          # get sort\*(Aqs results\&        or die "Can\*(Aqt open \*(Aqfoo\*(Aq for input: $!";.Ve.Sp\&\s-1FILEHANDLE\s0 may be an expression whose value can be used as an indirectfilehandle, usually the real filehandle name..IP "closedir \s-1DIRHANDLE\s0" 8.IX Xref "closedir".IX Item "closedir DIRHANDLE"Closes a directory opened by \f(CW\*(C`opendir\*(C'\fR and returns the success of thatsystem call..IP "connect \s-1SOCKET\s0,NAME" 8.IX Xref "connect".IX Item "connect SOCKET,NAME"Attempts to connect to a remote socket, just as the connect system calldoes.  Returns true if it succeeded, false otherwise.  \s-1NAME\s0 should be apacked address of the appropriate type for the socket.  See the examples in\&\*(L"Sockets: Client/Server Communication\*(R" in perlipc.

⌨️ 快捷键说明

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