📄 perlvar.1
字号:
By default, running out of memory is an untrappable, fatal error.However, if suitably built, Perl can use the contents of \f(CW$^M\fRas an emergency memory pool after \fIdie()\fRing. Suppose that your Perlwere compiled with \f(CW\*(C`\-DPERL_EMERGENCY_SBRK\*(C'\fR and used Perl's malloc.Then.Sp.Vb 1\& $^M = \*(Aqa\*(Aq x (1 << 16);.Ve.Spwould allocate a 64K buffer for use in an emergency. See the\&\fI\s-1INSTALL\s0\fR 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 English long name forthis variable..ie n .IP "$OSNAME" 8.el .IP "\f(CW$OSNAME\fR" 8.IX Item "$OSNAME".PD 0.IP "$^O" 8.IX Xref "$^O $OSNAME".IX Item "$^O".PDThe name of the operating system under which this copy of Perl wasbuilt, as determined during the configuration process. The valueis identical to \f(CW$Config{\*(Aqosname\*(Aq}\fR. See also Config and the \&\fB\-V\fR command-line switch documented in perlrun..SpIn Windows platforms, $^O is not very helpful: since it is always\&\f(CW\*(C`MSWin32\*(C'\fR, it doesn't tell the difference between95/98/ME/NT/2000/XP/CE/.NET. Use \fIWin32::GetOSName()\fR or\&\fIWin32::GetOSVersion()\fR (see Win32 and perlport) to distinguishbetween the variants..IP "${^OPEN}" 8.IX Item "${^OPEN}"An internal variable used by PerlIO. A string in two parts, separatedby a \f(CW\*(C`\e0\*(C'\fR byte, the first part describes the input layers, the secondpart describes the output layers..ie n .IP "$PERLDB" 8.el .IP "\f(CW$PERLDB\fR" 8.IX Item "$PERLDB".PD 0.IP "$^P" 8.IX Xref "$^P $PERLDB".IX Item "$^P".PDThe internal variable for debugging support. The meanings of thevarious bits are subject to change, but currently indicate:.RS 8.IP "0x01" 6.IX Item "0x01"Debug subroutine enter/exit..IP "0x02" 6.IX Item "0x02"Line-by-line debugging..IP "0x04" 6.IX Item "0x04"Switch off optimizations..IP "0x08" 6.IX Item "0x08"Preserve more data for future interactive inspections..IP "0x10" 6.IX Item "0x10"Keep info about source lines on which a subroutine is defined..IP "0x20" 6.IX Item "0x20"Start with single-step on..IP "0x40" 6.IX Item "0x40"Use subroutine address instead of name when reporting..IP "0x80" 6.IX Item "0x80"Report \f(CW\*(C`goto &subroutine\*(C'\fR as well..IP "0x100" 6.IX Item "0x100"Provide informative \*(L"file\*(R" names for evals based on the place they were compiled..IP "0x200" 6.IX Item "0x200"Provide informative names to anonymous subroutines based on the place theywere compiled..IP "0x400" 6.IX Item "0x400"Debug assertion subroutines enter/exit..RE.RS 8.SpSome bits may be relevant at compile-time only, some atrun-time only. This is a new mechanism and the details may change..RE.ie n .IP "$LAST_REGEXP_CODE_RESULT" 8.el .IP "\f(CW$LAST_REGEXP_CODE_RESULT\fR" 8.IX Item "$LAST_REGEXP_CODE_RESULT".PD 0.IP "$^R" 8.IX Xref "$^R $LAST_REGEXP_CODE_RESULT".IX Item "$^R".PDThe result of evaluation of the last successful \f(CW\*(C`(?{ code })\*(C'\fRregular expression assertion (see perlre). May be written to..ie n .IP "$EXCEPTIONS_BEING_CAUGHT" 8.el .IP "\f(CW$EXCEPTIONS_BEING_CAUGHT\fR" 8.IX Item "$EXCEPTIONS_BEING_CAUGHT".PD 0.IP "$^S" 8.IX Xref "$^S $EXCEPTIONS_BEING_CAUGHT".IX Item "$^S".PDCurrent state of the interpreter..Sp.Vb 5\& $^S State\& \-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\& undef Parsing module/eval\& true (1) Executing an eval\& false (0) Otherwise.Ve.SpThe first state may happen in \f(CW$SIG\fR{_\|_DIE_\|_} and \f(CW$SIG\fR{_\|_WARN_\|_} handlers..ie n .IP "$BASETIME" 8.el .IP "\f(CW$BASETIME\fR" 8.IX Item "$BASETIME".PD 0.IP "$^T" 8.IX Xref "$^T $BASETIME".IX Item "$^T".PDThe time at which the program began running, in seconds since theepoch (beginning of 1970). The values returned by the \fB\-M\fR, \fB\-A\fR,and \fB\-C\fR filetests are based on this value..IP "${^TAINT}" 8.IX Item "${^TAINT}"Reflects if taint mode is on or off. 1 for on (the program was run with\&\fB\-T\fR), 0 for off, \-1 when only taint warnings are enabled (i.e. with\&\fB\-t\fR or \fB\-TU\fR). This variable is read-only..IP "${^UNICODE}" 8.IX Item "${^UNICODE}"Reflects certain Unicode settings of Perl. See perlrundocumentation for the \f(CW\*(C`\-C\*(C'\fR switch for more information aboutthe possible values. This variable is set during Perl startupand is thereafter read-only..IP "${^UTF8CACHE}" 8.IX Item "${^UTF8CACHE}"This variable controls the state of the internal \s-1UTF\-8\s0 offset caching code.1 for on (the default), 0 for off, \-1 to debug the caching code by checkingall its results against linear scans, and panicking on any discrepancy..IP "${^UTF8LOCALE}" 8.IX Item "${^UTF8LOCALE}"This variable indicates whether an \s-1UTF\-8\s0 locale was detected by perl atstartup. This information is used by perl when it's inadjust\-utf8ness\-to\-locale mode (as when run with the \f(CW\*(C`\-CL\*(C'\fR command-lineswitch); see perlrun for more info on this..ie n .IP "$PERL_VERSION" 8.el .IP "\f(CW$PERL_VERSION\fR" 8.IX Item "$PERL_VERSION".PD 0.IP "$^V" 8.IX Xref "$^V $PERL_VERSION".IX Item "$^V".PDThe revision, version, and subversion of the Perl interpreter, representedas a \f(CW\*(C`version\*(C'\fR object..SpThis variable first appeared in perl 5.6.0; earlier versions of perl willsee an undefined value. Before perl 5.10.0 $^V was represented as a v\-string..Sp$^V can be used to determine whether the Perl interpreter executing ascript is in the right range of versions. (Mnemonic: use ^V for VersionControl.) Example:.Sp.Vb 1\& warn "Hashes not randomized!\en" if !$^V or $^V lt v5.8.1.Ve.SpTo convert \f(CW$^V\fR into its string representation use \fIsprintf()\fR's\&\f(CW"%vd"\fR conversion:.Sp.Vb 1\& printf "version is v%vd\en", $^V; # Perl\*(Aqs version.Ve.SpSee the documentation of \f(CW\*(C`use VERSION\*(C'\fR and \f(CW\*(C`require VERSION\*(C'\fRfor a convenient way to fail if the running Perl interpreter is too old..SpSee also \f(CW$]\fR for an older representation of the Perl version..ie n .IP "$WARNING" 8.el .IP "\f(CW$WARNING\fR" 8.IX Item "$WARNING".PD 0.IP "$^W" 8.IX Xref "$^W $WARNING".IX Item "$^W".PDThe current value of the warning switch, initially true if \fB\-w\fRwas used, false otherwise, but directly modifiable. (Mnemonic:related to the \fB\-w\fR switch.) See also warnings..IP "${^WARNING_BITS}" 8.IX Item "${^WARNING_BITS}"The current set of warning checks enabled by the \f(CW\*(C`use warnings\*(C'\fR pragma.See the documentation of \f(CW\*(C`warnings\*(C'\fR for more details..IP "${^WIN32_SLOPPY_STAT}" 8.IX Item "${^WIN32_SLOPPY_STAT}"If this variable is set to a true value, then \fIstat()\fR on Windows willnot try to open the file. This means that the link count cannot bedetermined and file attributes may be out of date if additionalhardlinks to the file exist. On the other hand, not opening the fileis considerably faster, especially for files on network drives..SpThis variable could be set in the \fIsitecustomize.pl\fR file toconfigure the local Perl installation to use \*(L"sloppy\*(R" \fIstat()\fR bydefault. See perlrun for more information about sitecustomization..ie n .IP "$EXECUTABLE_NAME" 8.el .IP "\f(CW$EXECUTABLE_NAME\fR" 8.IX Item "$EXECUTABLE_NAME".PD 0.IP "$^X" 8.IX Xref "$^X $EXECUTABLE_NAME".IX Item "$^X".PDThe name used to execute the current copy of Perl, from C's\&\f(CW\*(C`argv[0]\*(C'\fR or (where supported) \fI/proc/self/exe\fR..SpDepending on the host operating system, the value of $^X may bea relative or absolute pathname of the perl program file, or maybe the string used to invoke perl but not the pathname of theperl program file. Also, most operating systems permit invokingprograms that are not in the \s-1PATH\s0 environment variable, so thereis no guarantee that the value of $^X is in \s-1PATH\s0. For \s-1VMS\s0, thevalue may or may not include a version number..SpYou usually can use the value of $^X to re-invoke an independentcopy of the same perl that is currently running, e.g.,.Sp.Vb 1\& @first_run = \`$^X \-le "print int rand 100 for 1..100"\`;.Ve.SpBut recall that not all operating systems support forking orcapturing of the output of commands, so this complex statementmay not be portable..SpIt is not safe to use the value of $^X as a path name of a file,as some operating systems that have a mandatory suffix onexecutable files do not require use of the suffix when invokinga command. To convert the value of $^X to a path name, use thefollowing statements:.Sp.Vb 6\& # Build up a set of file names (not command names).\& use Config;\& $this_perl = $^X;\& if ($^O ne \*(AqVMS\*(Aq)\& {$this_perl .= $Config{_exe}\& unless $this_perl =~ m/$Config{_exe}$/i;}.Ve.SpBecause many operating systems permit anyone with read access tothe Perl program file to make a copy of it, patch the copy, andthen execute the copy, the security-conscious Perl programmershould take care to invoke the installed copy of perl, not thecopy referenced by $^X. The following statements accomplishthis goal, and produce a pathname that can be invoked as acommand or referenced as a file..Sp.Vb 5\& use Config;\& $secure_perl_path = $Config{perlpath};\& if ($^O ne \*(AqVMS\*(Aq)\& {$secure_perl_path .= $Config{_exe}\& unless $secure_perl_path =~ m/$Config{_exe}$/i;}.Ve.IP "\s-1ARGV\s0" 8.IX Xref "ARGV".IX Item "ARGV"The special filehandle that iterates over command-line filenames in\&\f(CW@ARGV\fR. Usually written as the null filehandle in the angle operator\&\f(CW\*(C`<>\*(C'\fR. Note that currently \f(CW\*(C`ARGV\*(C'\fR only has its magical effectwithin the \f(CW\*(C`<>\*(C'\fR operator; elsewhere it is just a plain filehandlecorresponding to the last file opened by \f(CW\*(C`<>\*(C'\fR. In particular,passing \f(CW\*(C`\e*ARGV\*(C'\fR as a parameter to a function that expects a filehandlemay not cause your function to automatically read the contents of all thefiles in \f(CW@ARGV\fR..ie n .IP "$ARGV" 8.el .IP "\f(CW$ARGV\fR" 8.IX Xref "$ARGV".IX Item "$ARGV"contains the name of the current file when reading from <>..ie n .IP "@ARGV" 8.el .IP "\f(CW@ARGV\fR" 8.IX Xref "@ARGV".IX Item "@ARGV"The array \f(CW@ARGV\fR contains the command-line arguments intended forthe script. \f(CW$#ARGV\fR is generally the number of arguments minusone, because \f(CW$ARGV[0]\fR is the first argument, \fInot\fR the program'scommand name itself. See \f(CW$0\fR for the command name..IP "\s-1ARGVOUT\s0" 8.IX Xref "ARGVOUT".IX Item "ARGVOUT"The special filehandle that points to the currently open output filewhen doing edit-in-place processing with \fB\-i\fR. Useful when you haveto do a lot of inserting and don't want to keep modifying \f(CW$_\fR. Seeperlrun for the \fB\-i\fR switch..ie n .IP "@F" 8.el .IP "\f(CW@F\fR" 8.IX Xref "@F".IX Item "@F"The array \f(CW@F\fR contains the fields of each line read in when autosplitmode is turned on. See perlrun for the \fB\-a\fR switch. This arrayis package-specific, and must be declared or given a full package nameif not in package main when running under \f(CW\*(C`strict \*(Aqvars\*(Aq\*(C'\fR..ie n .IP "@INC" 8.el .IP "\f(CW@INC\fR" 8.IX Xref "@INC".IX Item "@INC"The array \f(CW@INC\fR contains the list of places that the \f(CW\*(C`do EXPR\*(C'\fR,\&\f(CW\*(C`require\*(C'\fR, or \f(CW\*(C`use\*(C'\fR constructs look for their library files. Itinitially consists of the arguments to any \fB\-I\fR command-lineswitches, followed by the default Perl library, probably\&\fI/usr/local/lib/perl\fR, followed by \*(L".\*(R", to represent the currentdirectory. (\*(L".\*(R" will not be appended if taint checks are enabled, either by\&\f(CW\*(C`\-T\*(C'\fR or by \f(CW\*(C`\-t\*(C'\fR.) If you need to modify this at runtime, you should usethe \f(CW\*(C`use lib\*(C'\fR pragma to get the machine-dependent library properlyloaded also:.Sp.Vb 2\& use lib \*(Aq/mypath/libdir/\*(Aq;\& use SomeMod;.Ve.SpYou can also insert hooks into the file inclusion system by putting Perlcode directly into \f(CW@INC\fR. Those hooks may be subroutine references, arrayreferences or blessed objects. See \*(L"require\*(R" in perlfunc for details..ie n .IP "@ARG" 8.el .IP "\f(CW@ARG\fR" 8.IX Item "@ARG".PD 0.ie n .IP "@_" 8.el .IP "\f(CW@_\fR" 8.IX Xref "@_ @ARG".IX Item "@_".PDWithin a subroutine the array \f(CW@_\fR contains the parameters passed to thatsubroutine. See perlsub..ie n .IP "%INC" 8.el .IP "\f(CW%INC\fR" 8.IX Xref "%INC"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -