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

📄 perlvar.1

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 1
📖 第 1 页 / 共 5 页
字号:
Because of this specialness \f(CW$a\fR and \f(CW$b\fR don't need to be declared(using use vars, or \fIour()\fR) even when using the \f(CW\*(C`strict \*(Aqvars\*(Aq\*(C'\fR pragma.Don't lexicalize them with \f(CW\*(C`my $a\*(C'\fR or \f(CW\*(C`my $b\*(C'\fR if you want to beable to use them in the \fIsort()\fR comparison block or function..IP "$<\fIdigits\fR>" 8.IX Xref "$1 $2 $3".IX Item "$<digits>"Contains the subpattern from the corresponding set of capturingparentheses from the last pattern match, not counting patternsmatched in nested blocks that have been exited already.  (Mnemonic:like \edigits.)  These variables are all read-only and dynamicallyscoped to the current \s-1BLOCK\s0..ie n .IP "$MATCH" 8.el .IP "\f(CW$MATCH\fR" 8.IX Item "$MATCH".PD 0.IP "$&" 8.IX Xref "$& $MATCH".PDThe string matched by the last successful pattern match (not countingany matches hidden within a \s-1BLOCK\s0 or \fIeval()\fR enclosed by the current\&\s-1BLOCK\s0).  (Mnemonic: like & in some editors.)  This variable is read-onlyand dynamically scoped to the current \s-1BLOCK\s0..SpThe use of this variable anywhere in a program imposes a considerableperformance penalty on all regular expression matches.  See \*(L"\s-1BUGS\s0\*(R"..SpSee \*(L"@\-\*(R" for a replacement..IP "${^MATCH}" 8.IX Xref "${^MATCH}".IX Item "${^MATCH}"This is similar to \f(CW$&\fR (\f(CW$POSTMATCH\fR) except that it does not incur theperformance penalty associated with that variable, and is only guaranteedto return a defined value when the pattern was compiled or executed withthe \f(CW\*(C`/p\*(C'\fR modifier..ie n .IP "$PREMATCH" 8.el .IP "\f(CW$PREMATCH\fR" 8.IX Item "$PREMATCH".PD 0.IP "$`" 8.IX Xref "$` $PREMATCH".PDThe string preceding whatever was matched by the last successfulpattern match (not counting any matches hidden within a \s-1BLOCK\s0 or evalenclosed by the current \s-1BLOCK\s0).  (Mnemonic: \f(CW\*(C`\`\*(C'\fR often precedes a quotedstring.)  This variable is read-only..SpThe use of this variable anywhere in a program imposes a considerableperformance penalty on all regular expression matches.  See \*(L"\s-1BUGS\s0\*(R"..SpSee \*(L"@\-\*(R" for a replacement..IP "${^PREMATCH}" 8.IX Xref "${^PREMATCH}".IX Item "${^PREMATCH}"This is similar to \f(CW\*(C`$\`\*(C'\fR ($PREMATCH) except that it does not incur theperformance penalty associated with that variable, and is only guaranteedto return a defined value when the pattern was compiled or executed withthe \f(CW\*(C`/p\*(C'\fR modifier..ie n .IP "$POSTMATCH" 8.el .IP "\f(CW$POSTMATCH\fR" 8.IX Item "$POSTMATCH".PD 0.IP "$'" 8.IX Xref "$' $POSTMATCH".PDThe string following whatever was matched by the last successfulpattern match (not counting any matches hidden within a \s-1BLOCK\s0 or \fIeval()\fRenclosed by the current \s-1BLOCK\s0).  (Mnemonic: \f(CW\*(C`\*(Aq\*(C'\fR often follows a quotedstring.)  Example:.Sp.Vb 3\&    local $_ = \*(Aqabcdefghi\*(Aq;\&    /def/;\&    print "$\`:$&:$\*(Aq\en";         # prints abc:def:ghi.Ve.SpThis variable is read-only and dynamically scoped to the current \s-1BLOCK\s0..SpThe use of this variable anywhere in a program imposes a considerableperformance penalty on all regular expression matches.  See \*(L"\s-1BUGS\s0\*(R"..SpSee \*(L"@\-\*(R" for a replacement..IP "${^POSTMATCH}" 8.IX Xref "${^POSTMATCH}".IX Item "${^POSTMATCH}"This is similar to \f(CW\*(C`$\*(Aq\*(C'\fR (\f(CW$POSTMATCH\fR) except that it does not incur theperformance penalty associated with that variable, and is only guaranteedto return a defined value when the pattern was compiled or executed withthe \f(CW\*(C`/p\*(C'\fR modifier..ie n .IP "$LAST_PAREN_MATCH" 8.el .IP "\f(CW$LAST_PAREN_MATCH\fR" 8.IX Item "$LAST_PAREN_MATCH".PD 0.IP "$+" 8.IX Xref "$+ $LAST_PAREN_MATCH".PDThe text matched by the last bracket of the last successful search pattern.This is useful if you don't know which one of a set of alternative patternsmatched. For example:.Sp.Vb 1\&    /Version: (.*)|Revision: (.*)/ && ($rev = $+);.Ve.Sp(Mnemonic: be positive and forward looking.)This variable is read-only and dynamically scoped to the current \s-1BLOCK\s0..ie n .IP "$LAST_SUBMATCH_RESULT" 8.el .IP "\f(CW$LAST_SUBMATCH_RESULT\fR" 8.IX Item "$LAST_SUBMATCH_RESULT".PD 0.IP "$^N" 8.IX Xref "$^N".IX Item "$^N".PDThe text matched by the used group most-recently closed (i.e. the groupwith the rightmost closing parenthesis) of the last successful searchpattern.  (Mnemonic: the (possibly) Nested parenthesis that mostrecently closed.).SpThis is primarily used inside \f(CW\*(C`(?{...})\*(C'\fR blocks for examining textrecently matched. For example, to effectively capture text to a variable(in addition to \f(CW$1\fR, \f(CW$2\fR, etc.), replace \f(CW\*(C`(...)\*(C'\fR with.Sp.Vb 1\&     (?:(...)(?{ $var = $^N })).Ve.SpBy setting and then using \f(CW$var\fR in this way relieves you from having toworry about exactly which numbered set of parentheses they are..SpThis variable is dynamically scoped to the current \s-1BLOCK\s0..ie n .IP "@LAST_MATCH_END" 8.el .IP "\f(CW@LAST_MATCH_END\fR" 8.IX Item "@LAST_MATCH_END".PD 0.IP "@+" 8.IX Xref "@+ @LAST_MATCH_END".PDThis array holds the offsets of the ends of the last successfulsubmatches in the currently active dynamic scope.  \f(CW$+[0]\fR isthe offset into the string of the end of the entire match.  Thisis the same value as what the \f(CW\*(C`pos\*(C'\fR function returns when calledon the variable that was matched against.  The \fIn\fRth elementof this array holds the offset of the \fIn\fRth submatch, so\&\f(CW$+[1]\fR is the offset past where \f(CW$1\fR ends, \f(CW$+[2]\fR the offsetpast where \f(CW$2\fR ends, and so on.  You can use \f(CW$#+\fR to determinehow many subgroups were in the last successful match.  See theexamples given for the \f(CW\*(C`@\-\*(C'\fR variable..IP "%+" 8.IX Xref "%+"Similar to \f(CW\*(C`@+\*(C'\fR, the \f(CW\*(C`%+\*(C'\fR hash allows access to the named capturebuffers, should they exist, in the last successful match in thecurrently active dynamic scope..SpFor example, \f(CW$+{foo}\fR is equivalent to \f(CW$1\fR after the following match:.Sp.Vb 1\&  \*(Aqfoo\*(Aq =~ /(?<foo>foo)/;.Ve.SpThe keys of the \f(CW\*(C`%+\*(C'\fR hash list only the names of buffers that havecaptured (and that are thus associated to defined values)..SpThe underlying behaviour of \f(CW\*(C`%+\*(C'\fR is provided by theTie::Hash::NamedCapture module..Sp\&\fBNote:\fR \f(CW\*(C`%\-\*(C'\fR and \f(CW\*(C`%+\*(C'\fR are tied views into a common internal hashassociated with the last successful regular expression. Therefore mixingiterative access to them via \f(CW\*(C`each\*(C'\fR may have unpredictable results.Likewise, if the last successful match changes, then the results may besurprising..IP "\s-1HANDLE\-\s0>input_line_number(\s-1EXPR\s0)" 8.IX Item "HANDLE->input_line_number(EXPR)".PD 0.ie n .IP "$INPUT_LINE_NUMBER" 8.el .IP "\f(CW$INPUT_LINE_NUMBER\fR" 8.IX Item "$INPUT_LINE_NUMBER".ie n .IP "$NR" 8.el .IP "\f(CW$NR\fR" 8.IX Item "$NR".IP "$." 8.IX Xref "$. $NR $INPUT_LINE_NUMBER line number".PDCurrent line number for the last filehandle accessed..SpEach filehandle in Perl counts the number of lines that have been readfrom it.  (Depending on the value of \f(CW$/\fR, Perl's idea of whatconstitutes a line may not match yours.)  When a line is read from afilehandle (via \fIreadline()\fR or \f(CW\*(C`<>\*(C'\fR), or when \fItell()\fR or \fIseek()\fR iscalled on it, \f(CW$.\fR becomes an alias to the line counter for thatfilehandle..SpYou can adjust the counter by assigning to \f(CW$.\fR, but this will notactually move the seek pointer.  \fILocalizing \f(CI$.\fI will not localizethe filehandle's line count\fR.  Instead, it will localize perl's notionof which filehandle \f(CW$.\fR is currently aliased to..Sp\&\f(CW$.\fR is reset when the filehandle is closed, but \fBnot\fR when an openfilehandle is reopened without an intervening \fIclose()\fR.  For moredetails, see \*(L"I/O Operators\*(R" in perlop.  Because \f(CW\*(C`<>\*(C'\fR never doesan explicit close, line numbers increase across \s-1ARGV\s0 files (but seeexamples in \*(L"eof\*(R" in perlfunc)..SpYou can also use \f(CW\*(C`HANDLE\->input_line_number(EXPR)\*(C'\fR to access theline counter for a given filehandle without having to worry aboutwhich handle you last accessed..Sp(Mnemonic: many programs use \*(L".\*(R" to mean the current line number.).IP "IO::Handle\->input_record_separator(\s-1EXPR\s0)" 8.IX Item "IO::Handle->input_record_separator(EXPR)".PD 0.ie n .IP "$INPUT_RECORD_SEPARATOR" 8.el .IP "\f(CW$INPUT_RECORD_SEPARATOR\fR" 8.IX Item "$INPUT_RECORD_SEPARATOR".ie n .IP "$RS" 8.el .IP "\f(CW$RS\fR" 8.IX Item "$RS".IP "$/" 8.IX Xref "$ $RS $INPUT_RECORD_SEPARATOR".PDThe input record separator, newline by default.  This influences Perl's idea of what a \*(L"line\*(R" is.  Works like \fBawk\fR's \s-1RS\s0variable, including treating empty lines as a terminator if set tothe null string.  (An empty line cannot contain any spacesor tabs.)  You may set it to a multi-character string to match amulti-character terminator, or to \f(CW\*(C`undef\*(C'\fR to read through the endof file.  Setting it to \f(CW"\en\en"\fR means something slightlydifferent than setting to \f(CW""\fR, if the file contains consecutiveempty lines.  Setting to \f(CW""\fR will treat two or more consecutiveempty lines as a single empty line.  Setting to \f(CW"\en\en"\fR willblindly assume that the next input character belongs to the nextparagraph, even if it's a newline.  (Mnemonic: / delimitsline boundaries when quoting poetry.).Sp.Vb 3\&    local $/;           # enable "slurp" mode\&    local $_ = <FH>;    # whole file now here\&    s/\en[ \et]+/ /g;.Ve.SpRemember: the value of \f(CW$/\fR is a string, not a regex.  \fBawk\fR has to bebetter for something. :\-).SpSetting \f(CW$/\fR to a reference to an integer, scalar containing an integer, orscalar that's convertible to an integer will attempt to read recordsinstead of lines, with the maximum record size being the referencedinteger.  So this:.Sp.Vb 3\&    local $/ = \e32768; # or \e"32768", or \e$var_containing_32768\&    open my $fh, $myfile or die $!;\&    local $_ = <$fh>;.Ve.Spwill read a record of no more than 32768 bytes from \s-1FILE\s0.  If you'renot reading from a record-oriented file (or your \s-1OS\s0 doesn't haverecord-oriented files), then you'll likely get a full chunk of datawith every read.  If a record is larger than the record size you'veset, you'll get the record back in pieces.  Trying to set the recordsize to zero or less will cause reading in the (rest of the) whole file..SpOn \s-1VMS\s0, record reads are done with the equivalent of \f(CW\*(C`sysread\*(C'\fR,so it's best not to mix record and non-record reads on the samefile.  (This is unlikely to be a problem, because any file you'dwant to read in record mode is probably unusable in line mode.)Non-VMS systems do normal I/O, so it's safe to mix record andnon-record reads of a file..SpSee also \*(L"Newlines\*(R" in perlport.  Also see \f(CW$.\fR..IP "\s-1HANDLE\-\s0>autoflush(\s-1EXPR\s0)" 8.IX Item "HANDLE->autoflush(EXPR)".PD 0.ie n .IP "$OUTPUT_AUTOFLUSH" 8.el .IP "\f(CW$OUTPUT_AUTOFLUSH\fR" 8.IX Item "$OUTPUT_AUTOFLUSH".IP "$|" 8.IX Xref "$| autoflush flush $OUTPUT_AUTOFLUSH".PDIf set to nonzero, forces a flush right away and after every writeor print on the currently selected output channel.  Default is 0(regardless of whether the channel is really buffered by thesystem or not; \f(CW$|\fR tells you only whether you've asked Perlexplicitly to flush after each write).  \s-1STDOUT\s0 willtypically be line buffered if output is to the terminal and blockbuffered otherwise.  Setting this variable is useful primarily whenyou are outputting to a pipe or socket, such as when you are runninga Perl program under \fBrsh\fR and want to see the output as it'shappening.  This has no effect on input buffering.  See \*(L"getc\*(R" in perlfuncfor that.  (Mnemonic: when you want your pipes to be piping hot.).IP "IO::Handle\->output_field_separator \s-1EXPR\s0" 8.IX Item "IO::Handle->output_field_separator EXPR".PD 0.ie n .IP "$OUTPUT_FIELD_SEPARATOR" 8.el .IP "\f(CW$OUTPUT_FIELD_SEPARATOR\fR" 8.IX Item "$OUTPUT_FIELD_SEPARATOR".ie n .IP "$OFS" 8.el .IP "\f(CW$OFS\fR" 8.IX Item "$OFS".IP "$," 8.IX Xref "$, $OFS $OUTPUT_FIELD_SEPARATOR".PDThe output field separator for the print operator.  If defined, thisvalue is printed between each of print's arguments.  Default is \f(CW\*(C`undef\*(C'\fR.(Mnemonic: what is printed when there is a \*(L",\*(R" in your print statement.).IP "IO::Handle\->output_record_separator \s-1EXPR\s0" 8.IX Item "IO::Handle->output_record_separator EXPR".PD 0.ie n .IP "$OUTPUT_RECORD_SEPARATOR" 8.el .IP "\f(CW$OUTPUT_RECORD_SEPARATOR\fR" 8.IX Item "$OUTPUT_RECORD_SEPARATOR".ie n .IP "$ORS" 8.el .IP "\f(CW$ORS\fR" 8.IX Item "$ORS".IP "$\e" 8.IX Xref "$\e $ORS $OUTPUT_RECORD_SEPARATOR".IX Item "$".PDThe output record separator for the print operator.  If defined, thisvalue is printed after the last of print's arguments.  Default is \f(CW\*(C`undef\*(C'\fR.(Mnemonic: you set \f(CW\*(C`$\e\*(C'\fR instead of adding \*(L"\en\*(R" at the end of the print.Also, it's just like \f(CW$/\fR, but it's what you get \*(L"back\*(R" from Perl.).ie n .IP "$LIST_SEPARATOR" 8.el .IP "\f(CW$LIST_SEPARATOR\fR" 8.IX Item "$LIST_SEPARATOR".PD 0.IP "$""" 8.IX Xref "$"" $LIST_SEPARATOR".PDThis is like \f(CW$,\fR except that it applies to array and slice valuesinterpolated into a double-quoted string (or similar interpretedstring).  Default is a space.  (Mnemonic: obvious, I think.).ie n .IP "$SUBSCRIPT_SEPARATOR" 8.el .IP "\f(CW$SUBSCRIPT_SEPARATOR\fR" 8.IX Item "$SUBSCRIPT_SEPARATOR".PD 0.ie n .IP "$SUBSEP" 8.el .IP "\f(CW$SUBSEP\fR" 8.IX Item "$SUBSEP".IP "$;" 8.IX Xref "$; $SUBSEP SUBSCRIPT_SEPARATOR".PDThe subscript separator for multidimensional array emulation.  If yourefer to a hash element as.Sp.Vb 1\&    $foo{$a,$b,$c}.Ve.Sp

⌨️ 快捷键说明

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