perlvar.pod
来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· POD 代码 · 共 1,720 行 · 第 1/4 页
POD
1,720 行
scalar that's convertible to an integer will attempt to read recordsinstead of lines, with the maximum record size being the referencedinteger. So this: local $/ = \32768; # or \"32768", or \$var_containing_32768 open my $fh, $myfile or die $!; local $_ = <$fh>;will read a record of no more than 32768 bytes from FILE. If you'renot reading from a record-oriented file (or your OS 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.On VMS, record reads are done with the equivalent of C<sysread>,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.See also L<perlport/"Newlines">. Also see C<$.>.=item HANDLE->autoflush(EXPR)=item $OUTPUT_AUTOFLUSH=item $|X<$|> X<autoflush> X<flush> X<$OUTPUT_AUTOFLUSH>If 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; C<$|> tells you only whether you've asked Perlexplicitly to flush after each write). STDOUT 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 B<rsh> and want to see the output as it'shappening. This has no effect on input buffering. See L<perlfunc/getc>for that. (Mnemonic: when you want your pipes to be piping hot.)=item IO::Handle->output_field_separator EXPR=item $OUTPUT_FIELD_SEPARATOR=item $OFS=item $,X<$,> X<$OFS> X<$OUTPUT_FIELD_SEPARATOR>The output field separator for the print operator. If defined, thisvalue is printed between each of print's arguments. Default is C<undef>.(Mnemonic: what is printed when there is a "," in your print statement.)=item IO::Handle->output_record_separator EXPR=item $OUTPUT_RECORD_SEPARATOR=item $ORS=item $\X<$\> X<$ORS> X<$OUTPUT_RECORD_SEPARATOR>The output record separator for the print operator. If defined, thisvalue is printed after the last of print's arguments. Default is C<undef>.(Mnemonic: you set C<$\> instead of adding "\n" at the end of the print.Also, it's just like C<$/>, but it's what you get "back" from Perl.)=item $LIST_SEPARATOR=item $"X<$"> X<$LIST_SEPARATOR>This is like C<$,> 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.)=item $SUBSCRIPT_SEPARATOR=item $SUBSEP=item $;X<$;> X<$SUBSEP> X<SUBSCRIPT_SEPARATOR>The subscript separator for multidimensional array emulation. If yourefer to a hash element as $foo{$a,$b,$c}it really means $foo{join($;, $a, $b, $c)}But don't put @foo{$a,$b,$c} # a slice--note the @which means ($foo{$a},$foo{$b},$foo{$c})Default is "\034", the same as SUBSEP in B<awk>. If yourkeys contain binary data there might not be any safe value for C<$;>.(Mnemonic: comma (the syntactic subscript separator) is asemi-semicolon. Yeah, I know, it's pretty lame, but C<$,> is alreadytaken for something more important.)Consider using "real" multidimensional arrays as describedin L<perllol>.=item HANDLE->format_page_number(EXPR)=item $FORMAT_PAGE_NUMBER=item $%X<$%> X<$FORMAT_PAGE_NUMBER>The current page number of the currently selected output channel.Used with formats.(Mnemonic: % is page number in B<nroff>.)=item HANDLE->format_lines_per_page(EXPR)=item $FORMAT_LINES_PER_PAGE=item $=X<$=> X<$FORMAT_LINES_PER_PAGE>The current page length (printable lines) of the currently selectedoutput channel. Default is 60. Used with formats.(Mnemonic: = has horizontal lines.)=item HANDLE->format_lines_left(EXPR)=item $FORMAT_LINES_LEFT=item $-X<$-> X<$FORMAT_LINES_LEFT>The number of lines left on the page of the currently selected outputchannel. Used with formats.(Mnemonic: lines_on_page - lines_printed.)=item @LAST_MATCH_START=item @-X<@-> X<@LAST_MATCH_START>$-[0] is the offset of the start of the last successful match.C<$-[>I<n>C<]> is the offset of the start of the substring matched byI<n>-th subpattern, or undef if the subpattern did not match.Thus after a match against $_, $& coincides with C<substr $_, $-[0],$+[0] - $-[0]>. Similarly, $I<n> coincides with C<substr $_, $-[n],$+[n] - $-[n]> if C<$-[n]> is defined, and $+ coincides withC<substr $_, $-[$#-], $+[$#-] - $-[$#-]>. One can use C<$#-> to find the lastmatched subgroup in the last successful match. Contrast withC<$#+>, the number of subgroups in the regular expression. Comparewith C<@+>.This array holds the offsets of the beginnings of the lastsuccessful submatches in the currently active dynamic scope.C<$-[0]> is the offset into the string of the beginning of theentire match. The I<n>th element of this array holds the offsetof the I<n>th submatch, so C<$-[1]> is the offset where $1begins, C<$-[2]> the offset where $2 begins, and so on.After a match against some variable $var:=over 5=item C<$`> is the same as C<substr($var, 0, $-[0])>=item C<$&> is the same as C<substr($var, $-[0], $+[0] - $-[0])>=item C<$'> is the same as C<substr($var, $+[0])>=item C<$1> is the same as C<substr($var, $-[1], $+[1] - $-[1])> =item C<$2> is the same as C<substr($var, $-[2], $+[2] - $-[2])>=item C<$3> is the same as C<substr($var, $-[3], $+[3] - $-[3])>=back=item %-X<%->Similar to C<%+>, this variable allows access to the named capture buffersin the last successful match in the currently active dynamic scope. Toeach capture buffer name found in the regular expression, it associates areference to an array containing the list of values captured by allbuffers with that name (should there be several of them), in the orderwhere they appear.Here's an example: if ('1234' =~ /(?<A>1)(?<B>2)(?<A>3)(?<B>4)/) { foreach my $bufname (sort keys %-) { my $ary = $-{$bufname}; foreach my $idx (0..$#$ary) { print "\$-{$bufname}[$idx] : ", (defined($ary->[$idx]) ? "'$ary->[$idx]'" : "undef"), "\n"; } } }would print out: $-{A}[0] : '1' $-{A}[1] : '3' $-{B}[0] : '2' $-{B}[1] : '4'The keys of the C<%-> hash correspond to all buffer names found inthe regular expression.The behaviour of C<%-> is implemented via theL<Tie::Hash::NamedCapture> module.B<Note:> C<%-> and C<%+> are tied views into a common internal hashassociated with the last successful regular expression. Therefore mixingiterative access to them via C<each> may have unpredictable results.Likewise, if the last successful match changes, then the results may besurprising.=item HANDLE->format_name(EXPR)=item $FORMAT_NAME=item $~X<$~> X<$FORMAT_NAME>The name of the current report format for the currently selected outputchannel. Default is the name of the filehandle. (Mnemonic: brother toC<$^>.)=item HANDLE->format_top_name(EXPR)=item $FORMAT_TOP_NAME=item $^X<$^> X<$FORMAT_TOP_NAME>The name of the current top-of-page format for the currently selectedoutput channel. Default is the name of the filehandle with _TOPappended. (Mnemonic: points to top of page.)=item IO::Handle->format_line_break_characters EXPR=item $FORMAT_LINE_BREAK_CHARACTERS=item $:X<$:> X<FORMAT_LINE_BREAK_CHARACTERS>The current set of characters after which a string may be broken tofill continuation fields (starting with ^) in a format. Default isS<" \n-">, to break on whitespace or hyphens. (Mnemonic: a "colon" inpoetry is a part of a line.)=item IO::Handle->format_formfeed EXPR=item $FORMAT_FORMFEED=item $^LX<$^L> X<$FORMAT_FORMFEED>What formats output as a form feed. Default is \f.=item $ACCUMULATOR=item $^AX<$^A> X<$ACCUMULATOR>The current value of the write() accumulator for format() lines. A formatcontains formline() calls that put their result into C<$^A>. Aftercalling its format, write() prints out the contents of C<$^A> and empties.So you never really see the contents of C<$^A> unless you callformline() yourself and then look at it. See L<perlform> andL<perlfunc/formline()>.=item $CHILD_ERROR=item $?X<$?> X<$CHILD_ERROR>The status returned by the last pipe close, backtick (C<``>) command,successful call to wait() or waitpid(), or from the system()operator. This is just the 16-bit status word returned by thetraditional Unix wait() system call (or else is made up to look like it). Thus, theexit value of the subprocess is really (C<<< $? >> 8 >>>), andC<$? & 127> gives which signal, if any, the process died from, andC<$? & 128> reports whether there was a core dump. (Mnemonic:similar to B<sh> and B<ksh>.)Additionally, if the C<h_errno> variable is supported in C, its valueis returned via $? if any C<gethost*()> function fails.If you have installed a signal handler for C<SIGCHLD>, thevalue of C<$?> will usually be wrong outside that handler.Inside an C<END> subroutine C<$?> contains the value that is going to begiven to C<exit()>. You can modify C<$?> in an C<END> subroutine tochange the exit status of your program. For example: END { $? = 1 if $? == 255; # die would make it 255 } Under VMS, the pragma C<use vmsish 'status'> makes C<$?> reflect theactual VMS exit status, instead of the default emulation of POSIXstatus; see L<perlvms/$?> for details.Also see L<Error Indicators>.=item ${^CHILD_ERROR_NATIVE}X<$^CHILD_ERROR_NATIVE>The native status returned by the last pipe close, backtick (C<``>)command, successful call to wait() or waitpid(), or from the system()operator. On POSIX-like systems this value can be decoded with theWIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WIFSTOPPED, WSTOPSIGand WIFCONTINUED functions provided by the L<POSIX> module.Under VMS this reflects the actual VMS exit status; i.e. it is the sameas $? when the pragma C<use vmsish 'status'> is in effect.=item ${^ENCODING}X<$^ENCODING>The I<object reference> to the Encode object that is used to convertthe source code to Unicode. Thanks to this variable your perl scriptdoes not have to be written in UTF-8. Default is I<undef>. The directmanipulation of this variable is highly discouraged.=item $OS_ERROR=item $ERRNO=item $!X<$!> X<$ERRNO> X<$OS_ERROR>If used numerically, yields the current value of the C C<errno>variable, or in other words, if a system or library call fails, itsets this variable. This means that the value of C<$!> is meaningfulonly I<immediately> after a B<failure>: if (open(FH, $filename)) { # Here $! is meaningless. ... } else { # ONLY here is $! meaningful. ... # Already here $! might be meaningless. } # Since here we might have either success or failure, # here $! is meaningless.In the above I<meaningless> stands for anything: zero, non-zero,C<undef>. A successful system or library call does B<not> setthe variable to zero.If used as a string, yields the corresponding system error string.You can assign a number to C<$!> to set I<errno> if, for instance,you want C<"$!"> to return the string for error I<n>, or you wantto set the exit value for the die() operator. (Mnemonic: What justwent bang?)Also see L<Error Indicators>.=item %OS_ERROR=item %ERRNO=item %!X<%!>Each element of C<%!> has a true value only if C<$!> is set to thatvalue. For example, C<$!{ENOENT}> is true if and only if the currentvalue of C<$!> is C<ENOENT>; that is, if the most recent error was"No such file or directory" (or its moral equivalent: not all operatingsystems give that exact error, and certainly not all languages).To check if a particular key is meaningful on your system, useC<exists $!{the_key}>; for a list of legal keys, use C<keys %!>.See L<Errno> for more information, and also see above for thevalidity of C<$!>.=item $EXTENDED_OS_ERROR=item $^EX<$^E> X<$EXTENDED_OS_ERROR>Error information specific to the current operating system. Atthe moment, this differs from C<$!> under only VMS, OS/2, and Win32(and for MacPerl). On all other platforms, C<$^E> is always justthe same as C<$!>.Under VMS, C<$^E> provides the VMS status value from the lastsystem error. This is more specific information about the lastsystem error than that provided by C<$!>. This is particularlyimportant when C<$!> is set to B<EVMSERR>.Under OS/2, C<$^E> is set to the error code of the last call toOS/2 API either via CRT, or directly from perl.Under Win32, C<$^E> always returns the last error informationreported by the Win32 call C<GetLastError()> which describesthe last error from within the Win32 API. Most Win32-specificcode will report errors via C<$^E>. ANSI C and Unix-like callsset C<errno> and so most portable Perl code will report errorsvia C<$!>. Caveats mentioned in the description of C<$!> generally apply toC<$^E>, also. (Mnemonic: Extra error explanation.)Also see L<Error Indicators>.=item $EVAL_ERROR=item $@X<$@> X<$EVAL_ERROR>The Perl syntax error message from the last eval() operator.If $@ is the null string, the last eval() parsed and executedcorrectly (although the operations you invoked may have failed in the
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?