perlvar.pod
来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· POD 代码 · 共 1,720 行 · 第 1/4 页
POD
1,720 行
normal fashion). (Mnemonic: Where was the syntax error "at"?)Warning messages are not collected in this variable. You can,however, set up a routine to process warnings by setting C<$SIG{__WARN__}>as described below.Also see L<Error Indicators>.=item $PROCESS_ID=item $PID=item $$X<$$> X<$PID> X<$PROCESS_ID>The process number of the Perl running this script. You shouldconsider this variable read-only, although it will be alteredacross fork() calls. (Mnemonic: same as shells.)Note for Linux users: on Linux, the C functions C<getpid()> andC<getppid()> return different values from different threads. In order tobe portable, this behavior is not reflected by C<$$>, whose value remainsconsistent across threads. If you want to call the underlying C<getpid()>,you may use the CPAN module C<Linux::Pid>.=item $REAL_USER_ID=item $UID=item $<X<< $< >> X<$UID> X<$REAL_USER_ID>The real uid of this process. (Mnemonic: it's the uid you came I<from>,if you're running setuid.) You can change both the real uid andthe effective uid at the same time by using POSIX::setuid(). Sincechanges to $< require a system call, check $! after a change attempt to detect any possible errors.=item $EFFECTIVE_USER_ID=item $EUID=item $>X<< $> >> X<$EUID> X<$EFFECTIVE_USER_ID>The effective uid of this process. Example: $< = $>; # set real to effective uid ($<,$>) = ($>,$<); # swap real and effective uidYou can change both the effective uid and the real uid at the sametime by using POSIX::setuid(). Changes to $> require a check to $!to detect any possible errors after an attempted change. (Mnemonic: it's the uid you went I<to>, if you're running setuid.)C<< $< >> and C<< $> >> can be swapped only on machinessupporting setreuid().=item $REAL_GROUP_ID=item $GID=item $(X<$(> X<$GID> X<$REAL_GROUP_ID>The real gid of this process. If you are on a machine that supportsmembership in multiple groups simultaneously, gives a space separatedlist of groups you are in. The first number is the one returned bygetgid(), and the subsequent ones by getgroups(), one of which may bethe same as the first number.However, a value assigned to C<$(> must be a single number used toset the real gid. So the value given by C<$(> should I<not> be assignedback to C<$(> without being forced numeric, such as by adding zero. Notethat this is different to the effective gid (C<$)>) which does take alist.You can change both the real gid and the effective gid at the sametime by using POSIX::setgid(). Changes to $( require a check to $!to detect any possible errors after an attempted change.(Mnemonic: parentheses are used to I<group> things. The real gid is thegroup you I<left>, if you're running setgid.)=item $EFFECTIVE_GROUP_ID=item $EGID=item $)X<$)> X<$EGID> X<$EFFECTIVE_GROUP_ID>The effective gid of this process. If you are on a machine thatsupports membership in multiple groups simultaneously, gives a spaceseparated list of groups you are in. The first number is the onereturned by getegid(), and the subsequent ones by getgroups(), one ofwhich may be the same as the first number.Similarly, a value assigned to C<$)> must also be a space-separatedlist of numbers. The first number sets the effective gid, andthe rest (if any) are passed to setgroups(). To get the effect of anempty list for setgroups(), just repeat the new effective gid; that is,to force an effective gid of 5 and an effectively empty setgroups()list, say C< $) = "5 5" >.You can change both the effective gid and the real gid at the sametime by using POSIX::setgid() (use only a single numeric argument).Changes to $) require a check to $! to detect any possible errorsafter an attempted change.(Mnemonic: parentheses are used to I<group> things. The effective gidis the group that's I<right> for you, if you're running setgid.)C<< $< >>, C<< $> >>, C<$(> and C<$)> can be set only onmachines that support the corresponding I<set[re][ug]id()> routine. C<$(>and C<$)> can be swapped only on machines supporting setregid().=item $PROGRAM_NAME=item $0X<$0> X<$PROGRAM_NAME>Contains the name of the program being executed.On some (read: not all) operating systems assigning to C<$0> modifiesthe argument area that the C<ps> program sees. On some platforms youmay have to use special C<ps> options or a different C<ps> to see thechanges. Modifying the $0 is more useful as a way of indicating thecurrent program state than it is for hiding the program you'rerunning. (Mnemonic: same as B<sh> and B<ksh>.)Note that there are platform specific limitations on the maximumlength of C<$0>. In the most extreme case it may be limited to thespace occupied by the original C<$0>.In some platforms there may be arbitrary amount of padding, forexample space characters, after the modified name as shown by C<ps>.In some platforms this padding may extend all the way to the originallength of the argument area, no matter what you do (this is the casefor example with Linux 2.2).Note for BSD users: setting C<$0> does not completely remove "perl"from the ps(1) output. For example, setting C<$0> to C<"foobar"> mayresult in C<"perl: foobar (perl)"> (whether both the C<"perl: "> prefixand the " (perl)" suffix are shown depends on your exact BSD variantand version). This is an operating system feature, Perl cannot help it.In multithreaded scripts Perl coordinates the threads so that anythread may modify its copy of the C<$0> and the change becomes visibleto ps(1) (assuming the operating system plays along). Note thatthe view of C<$0> the other threads have will not change since theyhave their own copies of it.=item $[X<$[>The index of the first element in an array, and of the first characterin a substring. Default is 0, but you could theoretically set itto 1 to make Perl behave more like B<awk> (or Fortran) whensubscripting and when evaluating the index() and substr() functions.(Mnemonic: [ begins subscripts.)As of release 5 of Perl, assignment to C<$[> is treated as a compilerdirective, and cannot influence the behavior of any other file.(That's why you can only assign compile-time constants to it.)Its use is highly discouraged.Note that, unlike other compile-time directives (such as L<strict>),assignment to C<$[> can be seen from outer lexical scopes in the same file.However, you can use local() on it to strictly bind its value to alexical block.=item $]X<$]>The version + patchlevel / 1000 of the Perl interpreter. This variablecan be used to determine whether the Perl interpreter executing ascript is in the right range of versions. (Mnemonic: Is this versionof perl in the right bracket?) Example: warn "No checksumming!\n" if $] < 3.019;See also the documentation of C<use VERSION> and C<require VERSION>for a convenient way to fail if the running Perl interpreter is too old.The floating point representation can sometimes lead to inaccuratenumeric comparisons. See C<$^V> for a more modern representation ofthe Perl version that allows accurate string comparisons.=item $COMPILING=item $^CX<$^C> X<$COMPILING>The current value of the flag associated with the B<-c> switch.Mainly of use with B<-MO=...> to allow code to alter its behaviorwhen being compiled, such as for example to AUTOLOAD at compiletime rather than normal, deferred loading. SettingC<$^C = 1> is similar to calling C<B::minus_c>.=item $DEBUGGING=item $^DX<$^D> X<$DEBUGGING>The current value of the debugging flags. (Mnemonic: value of B<-D>switch.) May be read or set. Like its command-line equivalent, you can usenumeric or symbolic values, eg C<$^D = 10> or C<$^D = "st">.=item ${^RE_DEBUG_FLAGS}The current value of the regex debugging flags. Set to 0 for no debug outputeven when the re 'debug' module is loaded. See L<re> for details.=item ${^RE_TRIE_MAXBUF}Controls how certain regex optimisations are applied and how much memory theyutilize. This value by default is 65536 which corresponds to a 512kB temporarycache. Set this to a higher value to trade memory for speed when matchinglarge alternations. Set it to a lower value if you want the optimisations tobe as conservative of memory as possible but still occur, and set it to anegative value to prevent the optimisation and conserve the most memory.Under normal situations this variable should be of no interest to you.=item $SYSTEM_FD_MAX=item $^FX<$^F> X<$SYSTEM_FD_MAX>The maximum system file descriptor, ordinarily 2. System filedescriptors are passed to exec()ed processes, while higher filedescriptors are not. Also, during an open(), system file descriptors arepreserved even if the open() fails. (Ordinary file descriptors areclosed before the open() is attempted.) The close-on-execstatus of a file descriptor will be decided according to the value ofC<$^F> when the corresponding file, pipe, or socket was opened, not thetime of the exec().=item $^HWARNING: This variable is strictly for internal use only. Its availability,behavior, and contents are subject to change without notice.This variable contains compile-time hints for the Perl interpreter. At theend of compilation of a BLOCK the value of this variable is restored to thevalue when the interpreter started to compile the BLOCK.When perl begins to parse any block construct that provides a lexical scope(e.g., eval body, required file, subroutine body, loop body, or conditionalblock), the existing value of $^H is saved, but its value is left unchanged.When the compilation of the block is completed, it regains the saved value.Between the points where its value is saved and restored, code thatexecutes within BEGIN blocks is free to change the value of $^H.This behavior provides the semantic of lexical scoping, and is used in,for instance, the C<use strict> pragma.The contents should be an integer; different bits of it are used fordifferent pragmatic flags. Here's an example: sub add_100 { $^H |= 0x100 } sub foo { BEGIN { add_100() } bar->baz($boon); }Consider what happens during execution of the BEGIN block. At this pointthe BEGIN block has already been compiled, but the body of foo() is stillbeing compiled. The new value of $^H will therefore be visible only whilethe body of foo() is being compiled.Substitution of the above BEGIN block with: BEGIN { require strict; strict->import('vars') }demonstrates how C<use strict 'vars'> is implemented. Here's a conditionalversion of the same lexical pragma: BEGIN { require strict; strict->import('vars') if $condition }=item %^HThe %^H hash provides the same scoping semantic as $^H. This makes ituseful for implementation of lexically scoped pragmas. See L<perlpragma>.=item $INPLACE_EDIT=item $^IX<$^I> X<$INPLACE_EDIT>The current value of the inplace-edit extension. Use C<undef> to disableinplace editing. (Mnemonic: value of B<-i> switch.)=item $^MX<$^M>By default, running out of memory is an untrappable, fatal error.However, if suitably built, Perl can use the contents of C<$^M>as an emergency memory pool after die()ing. Suppose that your Perlwere compiled with C<-DPERL_EMERGENCY_SBRK> and used Perl's malloc.Then $^M = 'a' x (1 << 16);would allocate a 64K buffer for use in an emergency. See theF<INSTALL> file in the Perl distribution for information on how toadd custom C compilation flags when compiling perl. To discourage casualuse of this advanced feature, there is no L<English|English> long name forthis variable.=item $OSNAME=item $^OX<$^O> X<$OSNAME>The name of the operating system under which this copy of Perl wasbuilt, as determined during the configuration process. The valueis identical to C<$Config{'osname'}>. See also L<Config> and the B<-V> command-line switch documented in L<perlrun>.In Windows platforms, $^O is not very helpful: since it is alwaysC<MSWin32>, it doesn't tell the difference between95/98/ME/NT/2000/XP/CE/.NET. Use Win32::GetOSName() orWin32::GetOSVersion() (see L<Win32> and L<perlport>) to distinguishbetween the variants.=item ${^OPEN}An internal variable used by PerlIO. A string in two parts, separatedby a C<\0> byte, the first part describes the input layers, the secondpart describes the output layers.=item $PERLDB=item $^PX<$^P> X<$PERLDB>The internal variable for debugging support. The meanings of thevarious bits are subject to change, but currently indicate:=over 6=item 0x01Debug subroutine enter/exit.=item 0x02Line-by-line debugging.=item 0x04Switch off optimizations.=item 0x08Preserve more data for future interactive inspections.=item 0x10Keep info about source lines on which a subroutine is defined.=item 0x20Start with single-step on.=item 0x40Use subroutine address instead of name when reporting.=item 0x80Report C<goto &subroutine> as well.=item 0x100Provide informative "file" names for evals based on the place they were compiled.=item 0x200Provide informative names to anonymous subroutines based on the place theywere compiled.=item 0x400Debug assertion subroutines enter/exit.=backSome bits may be relevant at compile-time only, some atrun-time only. This is a new mechanism and the details may change.=item $LAST_REGEXP_CODE_RESULT=item $^RX<$^R> X<$LAST_REGEXP_CODE_RESULT>The result of evaluation of the last successful C<(?{ code })>regular expression assertion (see L<perlre>). May be written to.=item $EXCEPTIONS_BEING_CAUGHT=item $^SX<$^S> X<$EXCEPTIONS_BEING_CAUGHT>Current state of the interpreter. $^S State --------- ------------------- undef Parsing module/eval true (1) Executing an eval false (0) OtherwiseThe first state may happen in $SIG{__DIE__} and $SIG{__WARN__} handlers.=item $BASETIME=item $^TX<$^T> X<$BASETIME>The time at which the program began running, in seconds since theepoch (beginning of 1970). The values returned by the B<-M>, B<-A>,and B<-C> filetests are based on this value.=item ${^TAINT}Reflects if taint mode is on or off. 1 for on (the program was run withB<-T>), 0 for off, -1 when only taint warnings are enabled (i.e. withB<-t> or B<-TU>). This variable is read-only.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?