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

📄 perlrun.1

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 1
📖 第 1 页 / 共 4 页
字号:
\&    #!/usr/bin/perl \-spi.orig   # same as \-s \-p \-i.orig.Ve.PPSwitches include:.IP "\fB\-0\fR[\fIoctal/hexadecimal\fR]" 5.IX Xref "-0 $".IX Item "-0[octal/hexadecimal]"specifies the input record separator (\f(CW$/\fR) as an octal orhexadecimal number.  If there are no digits, the null character is theseparator.  Other switches may precede or follow the digits.  Forexample, if you have a version of \fBfind\fR which can print filenamesterminated by the null character, you can say this:.Sp.Vb 1\&    find . \-name \*(Aq*.orig\*(Aq \-print0 | perl \-n0e unlink.Ve.SpThe special value 00 will cause Perl to slurp files in paragraph mode.The value 0777 will cause Perl to slurp files whole because there is nolegal byte with that value..SpIf you want to specify any Unicode character, use the hexadecimalformat: \f(CW\*(C`\-0xHHH...\*(C'\fR, where the \f(CW\*(C`H\*(C'\fR are valid hexadecimal digits.(This means that you cannot use the \f(CW\*(C`\-x\*(C'\fR with a directory name thatconsists of hexadecimal digits.).IP "\fB\-a\fR" 5.IX Xref "-a autosplit".IX Item "-a"turns on autosplit mode when used with a \fB\-n\fR or \fB\-p\fR.  An implicitsplit command to the \f(CW@F\fR array is done as the first thing inside theimplicit while loop produced by the \fB\-n\fR or \fB\-p\fR..Sp.Vb 1\&    perl \-ane \*(Aqprint pop(@F), "\en";\*(Aq.Ve.Spis equivalent to.Sp.Vb 4\&    while (<>) {\&        @F = split(\*(Aq \*(Aq);\&        print pop(@F), "\en";\&    }.Ve.SpAn alternate delimiter may be specified using \fB\-F\fR..IP "\fB\-C [\f(BInumber/list\fB]\fR" 5.IX Xref "-C".IX Item "-C [number/list]"The \f(CW\*(C`\-C\*(C'\fR flag controls some of the Perl Unicode features..SpAs of 5.8.1, the \f(CW\*(C`\-C\*(C'\fR can be followed either by a number or a listof option letters.  The letters, their numeric values, and effectsare as follows; listing the letters is equal to summing the numbers..Sp.Vb 10\&    I     1   STDIN is assumed to be in UTF\-8\&    O     2   STDOUT will be in UTF\-8\&    E     4   STDERR will be in UTF\-8\&    S     7   I + O + E\&    i     8   UTF\-8 is the default PerlIO layer for input streams\&    o    16   UTF\-8 is the default PerlIO layer for output streams\&    D    24   i + o\&    A    32   the @ARGV elements are expected to be strings encoded\&              in UTF\-8\&    L    64   normally the "IOEioA" are unconditional,\&              the L makes them conditional on the locale environment\&              variables (the LC_ALL, LC_TYPE, and LANG, in the order\&              of decreasing precedence) \-\- if the variables indicate\&              UTF\-8, then the selected "IOEioA" are in effect\&    a   256   Set ${^UTF8CACHE} to \-1, to run the UTF\-8 caching code in\&              debugging mode..Ve.SpFor example, \f(CW\*(C`\-COE\*(C'\fR and \f(CW\*(C`\-C6\*(C'\fR will both turn on UTF\-8\-ness on both\&\s-1STDOUT\s0 and \s-1STDERR\s0.  Repeating letters is just redundant, not cumulativenor toggling..SpThe \f(CW\*(C`io\*(C'\fR options mean that any subsequent \fIopen()\fR (or similar I/Ooperations) will have the \f(CW\*(C`:utf8\*(C'\fR PerlIO layer implicitly appliedto them, in other words, \s-1UTF\-8\s0 is expected from any input stream,and \s-1UTF\-8\s0 is produced to any output stream.  This is just the default,with explicit layers in \fIopen()\fR and with \fIbinmode()\fR one can manipulatestreams as usual..Sp\&\f(CW\*(C`\-C\*(C'\fR on its own (not followed by any number or option list), or theempty string \f(CW""\fR for the \f(CW\*(C`PERL_UNICODE\*(C'\fR environment variable, has thesame effect as \f(CW\*(C`\-CSDL\*(C'\fR.  In other words, the standard I/O handles andthe default \f(CW\*(C`open()\*(C'\fR layer are UTF\-8\-fied \fBbut\fR only if the localeenvironment variables indicate a \s-1UTF\-8\s0 locale.  This behaviour followsthe \fIimplicit\fR (and problematic) \s-1UTF\-8\s0 behaviour of Perl 5.8.0..SpYou can use \f(CW\*(C`\-C0\*(C'\fR (or \f(CW"0"\fR for \f(CW\*(C`PERL_UNICODE\*(C'\fR) to explicitlydisable all the above Unicode features..SpThe read-only magic variable \f(CW\*(C`${^UNICODE}\*(C'\fR reflects the numeric valueof this setting.  This is variable is set during Perl startup and isthereafter read-only.  If you want runtime effects, use the three-arg\&\fIopen()\fR (see \*(L"open\*(R" in perlfunc), the two-arg \fIbinmode()\fR (see \*(L"binmode\*(R" in perlfunc),and the \f(CW\*(C`open\*(C'\fR pragma (see open)..Sp(In Perls earlier than 5.8.1 the \f(CW\*(C`\-C\*(C'\fR switch was a Win32\-only switchthat enabled the use of Unicode-aware \*(L"wide system call\*(R" Win32 APIs.This feature was practically unused, however, and the command lineswitch was therefore \*(L"recycled\*(R".).IP "\fB\-c\fR" 5.IX Xref "-c".IX Item "-c"causes Perl to check the syntax of the program and then exit withoutexecuting it.  Actually, it \fIwill\fR execute \f(CW\*(C`BEGIN\*(C'\fR, \f(CW\*(C`UNITCHECK\*(C'\fR,\&\f(CW\*(C`CHECK\*(C'\fR, and \f(CW\*(C`use\*(C'\fR blocks, because these are considered as occurringoutside the execution of your program.  \f(CW\*(C`INIT\*(C'\fR and \f(CW\*(C`END\*(C'\fR blocks,however, will be skipped..IP "\fB\-d\fR" 5.IX Xref "-d -dt".IX Item "-d".PD 0.IP "\fB\-dt\fR" 5.IX Item "-dt".PDruns the program under the Perl debugger.  See perldebug.If \fBt\fR is specified, it indicates to the debugger that threadswill be used in the code being debugged..IP "\fB\-d:\fR\fIfoo[=bar,baz]\fR" 5.IX Xref "-d -dt".IX Item "-d:foo[=bar,baz]".PD 0.IP "\fB\-dt:\fR\fIfoo[=bar,baz]\fR" 5.IX Item "-dt:foo[=bar,baz]".PDruns the program under the control of a debugging, profiling, ortracing module installed as Devel::foo. E.g., \fB\-d:DProf\fR executesthe program using the Devel::DProf profiler.  As with the \fB\-M\fRflag, options may be passed to the Devel::foo package where theywill be received and interpreted by the Devel::foo::import routine.The comma-separated list of options must follow a \f(CW\*(C`=\*(C'\fR character.If \fBt\fR is specified, it indicates to the debugger that threadswill be used in the code being debugged.See perldebug..IP "\fB\-D\fR\fIletters\fR" 5.IX Xref "-D DEBUGGING -DDEBUGGING".IX Item "-Dletters".PD 0.IP "\fB\-D\fR\fInumber\fR" 5.IX Item "-Dnumber".PDsets debugging flags.  To watch how it executes your program, use\&\fB\-Dtls\fR.  (This works only if debugging is compiled into yourPerl.)  Another nice value is \fB\-Dx\fR, which lists your compiledsyntax tree.  And \fB\-Dr\fR displays compiled regular expressions;the format of the output is explained in perldebguts..SpAs an alternative, specify a number instead of list of letters (e.g.,\&\fB\-D14\fR is equivalent to \fB\-Dtls\fR):.Sp.Vb 10\&        1  p  Tokenizing and parsing (with v, displays parse stack)\&        2  s  Stack snapshots (with v, displays all stacks)\&        4  l  Context (loop) stack processing\&        8  t  Trace execution\&       16  o  Method and overloading resolution\&       32  c  String/numeric conversions\&       64  P  Print profiling info, preprocessor command for \-P, source file input state\&      128  m  Memory allocation\&      256  f  Format processing\&      512  r  Regular expression parsing and execution\&     1024  x  Syntax tree dump\&     2048  u  Tainting checks\&     4096  U  Unofficial, User hacking (reserved for private, unreleased use)\&     8192  H  Hash dump \-\- usurps values()\&    16384  X  Scratchpad allocation\&    32768  D  Cleaning up\&    65536  S  Thread synchronization\&   131072  T  Tokenising\&   262144  R  Include reference counts of dumped variables (eg when using \-Ds)\&   524288  J  Do not s,t,P\-debug (Jump over) opcodes within package DB\&  1048576  v  Verbose: use in conjunction with other flags\&  2097152  C  Copy On Write\&  4194304  A  Consistency checks on internal structures\&  8388608  q  quiet \- currently only suppresses the "EXECUTING" message.Ve.SpAll these flags require \fB\-DDEBUGGING\fR when you compile the Perlexecutable (but see Devel::Peek, re which may change this).See the \fI\s-1INSTALL\s0\fR file in the Perl source distributionfor how to do this.  This flag is automatically set if you include \fB\-g\fRoption when \f(CW\*(C`Configure\*(C'\fR asks you about optimizer/debugger flags..SpIf you're just trying to get a print out of each line of Perl codeas it executes, the way that \f(CW\*(C`sh \-x\*(C'\fR provides for shell scripts,you can't use Perl's \fB\-D\fR switch.  Instead do this.Sp.Vb 2\&  # If you have "env" utility\&  env PERLDB_OPTS="NonStop=1 AutoTrace=1 frame=2" perl \-dS program\&\&  # Bourne shell syntax\&  $ PERLDB_OPTS="NonStop=1 AutoTrace=1 frame=2" perl \-dS program\&\&  # csh syntax\&  % (setenv PERLDB_OPTS "NonStop=1 AutoTrace=1 frame=2"; perl \-dS program).Ve.SpSee perldebug for details and variations..IP "\fB\-e\fR \fIcommandline\fR" 5.IX Xref "-e".IX Item "-e commandline"may be used to enter one line of program.  If \fB\-e\fR is given, Perlwill not look for a filename in the argument list.  Multiple \fB\-e\fRcommands may be given to build up a multi-line script.  Make sureto use semicolons where you would in a normal program..IP "\fB\-E\fR \fIcommandline\fR" 5.IX Xref "-E".IX Item "-E commandline"behaves just like \fB\-e\fR, except that it implicitly enables alloptional features (in the main compilation unit). See feature..IP "\fB\-f\fR" 5.IX Xref "-f".IX Item "-f"Disable executing \fI\f(CI$Config\fI{sitelib}/sitecustomize.pl\fR at startup..SpPerl can be built so that it by default will try to execute\&\fI\f(CI$Config\fI{sitelib}/sitecustomize.pl\fR at startup.  This is a hook thatallows the sysadmin to customize how perl behaves.  It can forinstance be used to add entries to the \f(CW@INC\fR array to make perl findmodules in non-standard locations..IP "\fB\-F\fR\fIpattern\fR" 5.IX Xref "-F".IX Item "-Fpattern"specifies the pattern to split on if \fB\-a\fR is also in effect.  Thepattern may be surrounded by \f(CW\*(C`//\*(C'\fR, \f(CW""\fR, or \f(CW\*(Aq\*(Aq\fR, otherwise it will beput in single quotes. You can't use literal whitespace in the pattern..IP "\fB\-h\fR" 5.IX Xref "-h".IX Item "-h"prints a summary of the options..IP "\fB\-i\fR[\fIextension\fR]" 5.IX Xref "-i in-place".IX Item "-i[extension]"specifies that files processed by the \f(CW\*(C`<>\*(C'\fR construct are to beedited in-place.  It does this by renaming the input file, opening theoutput file by the original name, and selecting that output file as thedefault for \fIprint()\fR statements.  The extension, if supplied, is used tomodify the name of the old file to make a backup copy, following theserules:.SpIf no extension is supplied, no backup is made and the current file isoverwritten..SpIf the extension doesn't contain a \f(CW\*(C`*\*(C'\fR, then it is appended to theend of the current filename as a suffix.  If the extension doescontain one or more \f(CW\*(C`*\*(C'\fR characters, then each \f(CW\*(C`*\*(C'\fR is replacedwith the current filename.  In Perl terms, you could think of thisas:.Sp.Vb 1\&    ($backup = $extension) =~ s/\e*/$file_name/g;.Ve.SpThis allows you to add a prefix to the backup file, instead of (or inaddition to) a suffix:.Sp.Vb 1\&    $ perl \-pi\*(Aqorig_*\*(Aq \-e \*(Aqs/bar/baz/\*(Aq fileA    # backup to \*(Aqorig_fileA\*(Aq.Ve.SpOr even to place backup copies of the original files into anotherdirectory (provided the directory already exists):.Sp.Vb 1\&    $ perl \-pi\*(Aqold/*.orig\*(Aq \-e \*(Aqs/bar/baz/\*(Aq fileA # backup to \*(Aqold/fileA.orig\*(Aq.Ve.SpThese sets of one-liners are equivalent:.Sp.Vb 2\&    $ perl \-pi \-e \*(Aqs/bar/baz/\*(Aq fileA            # overwrite current file\&    $ perl \-pi\*(Aq*\*(Aq \-e \*(Aqs/bar/baz/\*(Aq fileA         # overwrite current file\&\&    $ perl \-pi\*(Aq.orig\*(Aq \-e \*(Aqs/bar/baz/\*(Aq fileA     # backup to \*(AqfileA.orig\*(Aq\&    $ perl \-pi\*(Aq*.orig\*(Aq \-e \*(Aqs/bar/baz/\*(Aq fileA    # backup to \*(AqfileA.orig\*(Aq.Ve.SpFrom the shell, saying.Sp.Vb 1\&    $ perl \-p \-i.orig \-e "s/foo/bar/; ... ".Ve.Spis the same as using the program:.Sp.Vb 2\&    #!/usr/bin/perl \-pi.orig\&    s/foo/bar/;.Ve.Spwhich is equivalent to.Sp.Vb 10\&    #!/usr/bin/perl\&    $extension = \*(Aq.orig\*(Aq;\&    LINE: while (<>) {\&        if ($ARGV ne $oldargv) {\&            if ($extension !~ /\e*/) {\&                $backup = $ARGV . $extension;\&            }\&            else {\&                ($backup = $extension) =~ s/\e*/$ARGV/g;\&            }\&            rename($ARGV, $backup);\&            open(ARGVOUT, ">$ARGV");\&            select(ARGVOUT);\&            $oldargv = $ARGV;\&        }\&        s/foo/bar/;\&    }\&    continue {\&        print;  # this prints to original filename\&    }\&    select(STDOUT);.Ve.Spexcept that the \fB\-i\fR form doesn't need to compare \f(CW$ARGV\fR to \f(CW$oldargv\fR toknow when the filename has changed.  It does, however, use \s-1ARGVOUT\s0 forthe selected filehandle.  Note that \s-1STDOUT\s0 is restored as the defaultoutput filehandle after the loop..SpAs shown above, Perl creates the backup file whether or not any outputis actually changed.  So this is just a fancy way to copy files:.Sp.Vb 3\&    $ perl \-p \-i\*(Aq/some/file/path/*\*(Aq \-e 1 file1 file2 file3...\&or\&    $ perl \-p \-i\*(Aq.orig\*(Aq \-e 1 file1 file2 file3....Ve.SpYou can use \f(CW\*(C`eof\*(C'\fR without parentheses to locate the end of each inputfile, in case you want to append to each file, or reset line numbering(see example in \*(L"eof\*(R" in perlfunc)..SpIf, for a given file, Perl is unable to create the backup file asspecified in the extension then it will skip that file and continue onwith the next one (if it exists)..SpFor a discussion of issues surrounding file permissions and \fB\-i\fR,see \*(L"Why does Perl let me delete read-only files?  Why does \-i clobber protected files?  Isn't this a bug in Perl?\*(R" in perlfaq5..SpYou cannot use \fB\-i\fR to create directories or to strip extensions fromfiles..SpPerl does not expand \f(CW\*(C`~\*(C'\fR in filenames, which is good, since somefolks use it for their backup files:.Sp.Vb 1\&    $ perl \-pi~ \-e \*(Aqs/foo/bar/\*(Aq file1 file2 file3....Ve.SpNote that because \fB\-i\fR renames or deletes the original file beforecreating a new file of the same name, UNIX-style soft and hard links willnot be preserved..SpFinally, the \fB\-i\fR switch does not impede execution when nofiles are given on the command line.  In this case, no backup is made(the original file cannot, of course, be determined) and processingproceeds from \s-1STDIN\s0 to \s-1STDOUT\s0 as might be expected..IP "\fB\-I\fR\fIdirectory\fR" 5

⌨️ 快捷键说明

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