📄 perlvms.1
字号:
.IP "Any other string" 4.IX Item "Any other string"If an element of \fI\s-1PERL_ENV_TABLES\s0\fR translates to any other string,that string is used as the name of a logical name table, which isconsulted using \fIname\fR as the logical name. The normal searchorder of access modes is used..RE.RS 4.Sp\&\fI\s-1PERL_ENV_TABLES\s0\fR is translated once when Perl starts up; any changesyou make while Perl is running do not affect the behavior of \f(CW%ENV\fR.If \fI\s-1PERL_ENV_TABLES\s0\fR is not defined, then Perl defaults to consultingfirst the logical name tables specified by \fI\s-1LNM$FILE_DEV\s0\fR, and thenthe \s-1CRTL\s0 \f(CW\*(C`environ\*(C'\fR array..SpIn all operations on \f(CW%ENV\fR, the key string is treated as if it were entirely uppercase, regardless of the case actually specified in the Perl expression..SpWhen an element of \f(CW%ENV\fR is read, the locations to which\&\fI\s-1PERL_ENV_TABLES\s0\fR points are checked in order, and the valueobtained from the first successful lookup is returned. If thename of the \f(CW%ENV\fR element contains a semi-colon, it andany characters after it are removed. These are ignored whenthe \s-1CRTL\s0 \f(CW\*(C`environ\*(C'\fR array or a \s-1CLI\s0 symbol table is consulted.However, the name is looked up in a logical name table, thesuffix after the semi-colon is treated as the translation indexto be used for the lookup. This lets you look up successive valuesfor search list logical names. For instance, if you say.Sp.Vb 3\& $ Define STORY once,upon,a,time,there,was\& $ perl \-e "for ($i = 0; $i <= 6; $i++) " \-\& _$ \-e "{ print $ENV{\*(Aqstory;\*(Aq.$i},\*(Aq \*(Aq}".Ve.SpPerl will print \f(CW\*(C`ONCE UPON A TIME THERE WAS\*(C'\fR, assuming, of course,that \fI\s-1PERL_ENV_TABLES\s0\fR is set up so that the logical name \f(CW\*(C`story\*(C'\fRis found, rather than a \s-1CLI\s0 symbol or \s-1CRTL\s0 \f(CW\*(C`environ\*(C'\fR element withthe same name..SpWhen an element of \f(CW%ENV\fR is set to a defined string, thecorresponding definition is made in the location to which thefirst translation of \fI\s-1PERL_ENV_TABLES\s0\fR points. If this causes alogical name to be created, it is defined in supervisor mode.(The same is done if an existing logical name was defined inexecutive or kernel mode; an existing user or supervisor modelogical name is reset to the new value.) If the value is an emptystring, the logical name's translation is defined as a single \s-1NUL\s0(\s-1ASCII\s0 00) character, since a logical name cannot translate to azero-length string. (This restriction does not apply to \s-1CLI\s0 symbolsor \s-1CRTL\s0 \f(CW\*(C`environ\*(C'\fR values; they are set to the empty string.)An element of the \s-1CRTL\s0 \f(CW\*(C`environ\*(C'\fR array can be set only if yourcopy of Perl knows about the \s-1CRTL\s0's \f(CW\*(C`setenv()\*(C'\fR function. (This ispresent only in some versions of the \s-1DECCRTL\s0; check \f(CW$Config{d_setenv}\fRto see whether your copy of Perl was built with a \s-1CRTL\s0 that has thisfunction.).SpWhen an element of \f(CW%ENV\fR is set to \f(CW\*(C`undef\*(C'\fR,the element is looked up as if it were being read, and if it isfound, it is deleted. (An item \*(L"deleted\*(R" from the \s-1CRTL\s0 \f(CW\*(C`environ\*(C'\fRarray is set to the empty string; this can only be done if yourcopy of Perl knows about the \s-1CRTL\s0 \f(CW\*(C`setenv()\*(C'\fR function.) Using\&\f(CW\*(C`delete\*(C'\fR to remove an element from \f(CW%ENV\fR has a similar effect,but after the element is deleted, another attempt is made tolook up the element, so an inner-mode logical name or a name inanother location will replace the logical name just deleted.In either case, only the first value found searching \s-1PERL_ENV_TABLES\s0is altered. It is not possible at present to define a search listlogical name via \f(CW%ENV\fR..SpThe element \f(CW$ENV{DEFAULT}\fR is special: when read, it returnsPerl's current default device and directory, and when set, itresets them, regardless of the definition of \fI\s-1PERL_ENV_TABLES\s0\fR.It cannot be cleared or deleted; attempts to do so are silentlyignored..SpNote that if you want to pass on any elements of theC\-local environ array to a subprocess which isn'tstarted by fork/exec, or isn't running a C program, youcan \*(L"promote\*(R" them to logical names in the currentprocess, which will then be inherited by all subprocesses,by saying.Sp.Vb 4\& foreach my $key (qw[C\-local keys you want promoted]) {\& my $temp = $ENV{$key}; # read from C\-local array\& $ENV{$key} = $temp; # and define as logical name\& }.Ve.Sp(You can't just say \f(CW$ENV{$key} = $ENV{$key}\fR, since thePerl optimizer is smart enough to elide the expression.).SpDon't try to clear \f(CW%ENV\fR by saying \f(CW\*(C`%ENV = ();\*(C'\fR, it will throwa fatal error. This is equivalent to doing the following from \s-1DCL:\s0.Sp.Vb 1\& DELETE/LOGICAL *.Ve.SpYou can imagine how bad things would be if, for example, the \s-1SYS$MANAGER\s0or \s-1SYS$SYSTEM\s0 logical names were deleted..SpAt present, the first time you iterate over \f(CW%ENV\fR using\&\f(CW\*(C`keys\*(C'\fR, or \f(CW\*(C`values\*(C'\fR, you will incur a time penalty as alllogical names are read, in order to fully populate \f(CW%ENV\fR.Subsequent iterations will not reread logical names, so theywon't be as slow, but they also won't reflect any changesto logical name tables caused by other programs..SpYou do need to be careful with the logical names representingprocess-permanent files, such as \f(CW\*(C`SYS$INPUT\*(C'\fR and \f(CW\*(C`SYS$OUTPUT\*(C'\fR.The translations for these logical names are prepended with atwo-byte binary value (0x1B 0x00) that needs to be stripped offif you wantto use it. (In previous versions of Perl it wasn'tpossible to get the values of these logical names, as the nullbyte acted as an end-of-string marker).RE.IP "$!" 4The string value of \f(CW$!\fR is that returned by the \s-1CRTL\s0's\&\fIstrerror()\fR function, so it will include the \s-1VMS\s0 message forVMS-specific errors. The numeric value of \f(CW$!\fR is thevalue of \f(CW\*(C`errno\*(C'\fR, except if errno is \s-1EVMSERR\s0, in whichcase \f(CW$!\fR contains the value of vaxc$errno. Setting \f(CW$!\fRalways sets errno to the value specified. If this value is\&\s-1EVMSERR\s0, it also sets vaxc$errno to 4 (NONAME-F-NOMSG), sothat the string value of \f(CW$!\fR won't reflect the \s-1VMS\s0 errormessage from before \f(CW$!\fR was set..IP "$^E" 4.IX Item "$^E"This variable provides direct access to \s-1VMS\s0 status valuesin vaxc$errno, which are often more specific than thegeneric Unix-style error messages in \f(CW$!\fR. Its numeric valueis the value of vaxc$errno, and its string value is thecorresponding \s-1VMS\s0 message string, as retrieved by sys$\fIgetmsg()\fR.Setting \f(CW$^E\fR sets vaxc$errno to the value specified..SpWhile Perl attempts to keep the vaxc$errno value to be current, iferrno is not \s-1EVMSERR\s0, it may not be from the current operation..IP "$?" 4The \*(L"status value\*(R" returned in \f(CW$?\fR is synthesized from theactual exit status of the subprocess in a way that approximates\&\s-1POSIX\s0 \fIwait\fR\|(5) semantics, in order to allow Perl programs toportably test for successful completion of subprocesses. Thelow order 8 bits of \f(CW$?\fR are always 0 under \s-1VMS\s0, since thetermination status of a process may or may not have beengenerated by an exception..SpThe next 8 bits contain the termination status of the program..SpIf the child process follows the convention of C programscompiled with the _POSIX_EXIT macro set, the status value willcontain the actual value of 0 to 255 returned by that programon a normal exit..SpWith the _POSIX_EXIT macro set, the \s-1UNIX\s0 exit value of zero isrepresented as a \s-1VMS\s0 native status of 1, and the \s-1UNIX\s0 valuesfrom 2 to 255 are encoded by the equation:.Sp.Vb 1\& VMS_status = 0x35a000 + (unix_value * 8) + 1..Ve.SpAnd in the special case of unix value 1 the encoding is:.Sp.Vb 1\& VMS_status = 0x35a000 + 8 + 2 + 0x10000000..Ve.SpFor other termination statuses, the severity portion of thesubprocess' exit status is used: if the severity was success orinformational, these bits are all 0; if the severity waswarning, they contain a value of 1; if the severity waserror or fatal error, they contain the actual severity bits,which turns out to be a value of 2 for error and 4 for severe_error.Fatal is another term for the severe_error status..SpAs a result, \f(CW$?\fR will always be zero if the subprocess' exitstatus indicated successful completion, and non-zero if awarning or error occurred or a program compliant with encoding_POSIX_EXIT values was run and set a status..SpHow can you tell the difference between a non-zero status that isthe result of a \s-1VMS\s0 native error status or an encoded \s-1UNIX\s0 status?You can not unless you look at the ${^CHILD_ERROR_NATIVE} value.The ${^CHILD_ERROR_NATIVE} value returns the actual \s-1VMS\s0 status valueand check the severity bits. If the severity bits are equal to 1,then if the numeric value for \f(CW$?\fR is between 2 and 255 or 0, then\&\f(CW$?\fR accurately reflects a value passed back from a \s-1UNIX\s0 application.If \f(CW$?\fR is 1, and the severity bits indicate a \s-1VMS\s0 error (2), then\&\f(CW$?\fR is from a \s-1UNIX\s0 application exit value..SpIn practice, Perl scripts that call programs that return _POSIX_EXITtype status values will be expecting those values, and programs thatcall traditional \s-1VMS\s0 programs will either be expecting the previousbehavior or just checking for a non-zero status..SpAnd success is always the value 0 in all behaviors..SpWhen the actual \s-1VMS\s0 termination status of the child is an error,internally the \f(CW$!\fR value will be set to the closest \s-1UNIX\s0 errnovalue to that error so that Perl scripts that test for errormessages will see the expected \s-1UNIX\s0 style error message insteadof a \s-1VMS\s0 message..SpConversely, when setting \f(CW$?\fR in an \s-1END\s0 block, an attempt is madeto convert the \s-1POSIX\s0 value into a native status intelligible tothe operating system upon exiting Perl. What this boils down tois that setting \f(CW$?\fR to zero results in the generic success value\&\s-1SS$_NORMAL\s0, and setting \f(CW$?\fR to a non-zero value results in thegeneric failure status \s-1SS$_ABORT\s0. See also \*(L"exit\*(R" in perlport..SpWith the future \s-1POSIX_EXIT\s0 mode set, setting \f(CW$?\fR will cause thenew value to also be encoded into \f(CW$^E\fR so that the either theoriginal parent or child exit status values of 0 to 255can be automatically recovered by C programs expecting _POSIX_EXITbehavior. If both a parent and a child exit value are non-zero, then itwill be assumed that this is actually a \s-1VMS\s0 native status value tobe passed through. The special value of 0xFFFF is almost a \s-1NOOP\s0 asit will cause the current native \s-1VMS\s0 status in the C library tobecome the current native Perl \s-1VMS\s0 status, and is handled this wayas consequence of it known to not be a valid native \s-1VMS\s0 status value.It is recommend that only values in range of normal \s-1UNIX\s0 parent orchild status numbers, 0 to 255 are used..SpThe pragma \f(CW\*(C`use vmsish \*(Aqstatus\*(Aq\*(C'\fR makes \f(CW$?\fR reflect the actual \&\s-1VMS\s0 exit status instead of the default emulation of \s-1POSIX\s0 status described above. This pragma also disables the conversion ofnon-zero values to \s-1SS$_ABORT\s0 when setting \f(CW$?\fR in an \s-1END\s0block (but zero will still be converted to \s-1SS$_NORMAL\s0)..SpDo not use the pragma \f(CW\*(C`use vmsish \*(Aqstatus\*(Aq\*(C'\fR with the future\&\s-1POSIX_EXIT\s0 mode, as they are at times requesting conflictingactions and the consequence of ignoring this advice will beundefined to allow future improvements in the \s-1POSIX\s0 exit handling..IP "$|" 4Setting \f(CW$|\fR for an I/O stream causes data to be flushedall the way to disk on each write (\fIi.e.\fR not just tothe underlying \s-1RMS\s0 buffers for a file). In other words,it's equivalent to calling \fIfflush()\fR and \fIfsync()\fR from C..SH "Standard modules with VMS-specific differences".IX Header "Standard modules with VMS-specific differences".Sh "SDBM_File".IX Subsection "SDBM_File"SDBM_File works properly on \s-1VMS\s0. It has, however, one minordifference. The database directory file created has a \fI.sdbm_dir\fRextension rather than a \fI.dir\fR extension. \fI.dir\fR files are \s-1VMS\s0 filesystemdirectory files, and using them for other purposes could cause unacceptableproblems..SH "Revision date".IX Header "Revision date"This document was last updated on 3\-Dec\-2007, for Perl 5,patchlevel 10..SH "AUTHOR".IX Header "AUTHOR"Charles Bailey bailey@cor.newman.upenn.eduCraig Berry craigberry@mac.comDan Sugalski dan@sidhe.orgJohn Malmberg wb8tyw@qsl.net
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -