perlvms.pod

来自「MSYS在windows下模拟了一个类unix的终端」· POD 代码 · 共 886 行 · 第 1/3 页

POD
886
字号
Therefore, the "system time" elements will always be 0, since there is no difference between "user time" and "system" time under VMS, and the time accumulated by a subprocess may or may not appear separately in the "child time" field, depending on whether L<times> keeps track of subprocesses separately.  Noteespecially that the VAXCRTL (at least) keeps track only ofsubprocesses spawned using L<fork> and L<exec>; it will notaccumulate the times of subprocesses spawned via pipes, L<system>,or backticks.=item unlink LISTC<unlink> will delete the highest version of a file only; inorder to delete all versions, you need to say    1 while (unlink LIST);You may need to make this change to scripts written for aUnix system which expect that after a call to C<unlink>,no files with the names passed to C<unlink> will exist.(Note: This can be changed at compile time; if youC<use Config> and C<$Config{'d_unlink_all_versions'}> isC<define>, then C<unlink> will delete all versions of afile on the first call.)C<unlink> will delete a file if at all possible, even if itrequires changing file protection (though it won't try tochange the protection of the parent directory).  You can tellwhether you've got explicit delete access to a file by using theC<VMS::Filespec::candelete> operator.  For instance, in orderto delete only files to which you have delete access, you couldsay something like    sub safe_unlink {        my($file,$num);        foreach $file (@_) {            next unless VMS::Filespec::candelete($file);            $num += unlink $file;        }        $num;    }(or you could just use C<VMS::Stdio::remove>, if you've installedthe VMS::Stdio extension distributed with Perl). If C<unlink> has tochange the file protection to delete the file, and you interrupt itin midstream, the file may be left intact, but with a changed ACLallowing you delete access.=item utime LISTSince ODS-2, the VMS file structure for disk files, does not keeptrack of access times, this operator changes only the modificationtime of the file (VMS revision date).=item waitpid PID,FLAGSIf PID is a subprocess started by a piped C<open()> (see L<open>), C<waitpid> will wait for that subprocess, and return its finalstatus value.  If PID is a subprocess created in some other way(e.g. SPAWNed before Perl was invoked), or is not a subprocess ofthe current process, C<waitpid> will check once per second whetherthe process has completed, and when it has, will return 0.  (If PIDspecifies a process that isn't a subprocess of the current process,and you invoked Perl with the C<-w> switch, a warning will be issued.)The FLAGS argument is ignored in all cases.=back=head1 Perl variablesThe following VMS-specific information applies to the indicated"special" Perl variables, in addition to the general informationin L<perlvar>.  Where there is a conflict, this informationtakes precedence.=over 4=item %ENV The operation of the C<%ENV> array depends on the translationof the logical name F<PERL_ENV_TABLES>.  If defined, it shouldbe a search list, each element of which specifies a locationfor C<%ENV> elements.  If you tell Perl to read or set theelement C<$ENV{>I<name>C<}>, then Perl uses the translations ofF<PERL_ENV_TABLES> as follows:=over 4=item CRTL_ENVThis string tells Perl to consult the CRTL's internal C<environ>array of key-value pairs, using I<name> as the key.  In most cases,this contains only a few keys, but if Perl was invoked via the CC<exec[lv]e()> function, as is the case for CGI processing by someHTTP servers, then the C<environ> array may have been populated bythe calling program.=item CLISYM_[LOCAL]A string beginning with C<CLISYM_>tells Perl to consult the CLI'ssymbol tables, using I<name> as the name of the symbol.  When readingan element of C<%ENV>, the local symbol table is scanned first, followedby the global symbol table..  The characters following C<CLISYM_> aresignificant when an element of C<%ENV> is set or deleted: if thecomplete string is C<CLISYM_LOCAL>, the change is made in the localsymbol table; otherwise the global symbol table is changed.=item Any other stringIf an element of F<PERL_ENV_TABLES> translates to any other string,that string is used as the name of a logical name table, which isconsulted using I<name> as the logical name.  The normal searchorder of access modes is used.=backF<PERL_ENV_TABLES> is translated once when Perl starts up; any changesyou make while Perl is running do not affect the behavior of C<%ENV>.If F<PERL_ENV_TABLES> is not defined, then Perl defaults to consultingfirst the logical name tables specified by F<LNM$FILE_DEV>, and thenthe CRTL C<environ> array.In all operations on %ENV, the key string is treated as if it were entirely uppercase, regardless of the case actually specified in the Perl expression.When an element of C<%ENV> is read, the locations to whichF<PERL_ENV_TABLES> points are checked in order, and the valueobtained from the first successful lookup is returned.  If thename of the C<%ENV> element contains a semi-colon, it andany characters after it are removed.  These are ignored whenthe CRTL C<environ> array or a CLI 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   $  Define STORY  once,upon,a,time,there,was   $  perl -e "for ($i = 0; $i <= 6; $i++) " -   _$ -e "{ print $ENV{'story;'.$i},' '}"Perl will print C<ONCE UPON A TIME THERE WAS>, assuming, of course,that F<PERL_ENV_TABLES> is set up so that the logical name C<story>is found, rather than a CLI symbol or CRTL C<environ> element withthe same name.When an element of C<%ENV> is set to a defined string, thecorresponding definition is made in the location to which thefirst translation of F<PERL_ENV_TABLES> 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 NUL(ASCII 00) character, since a logical name cannot translate to azero-length string.  (This restriction does not apply to CLI symbolsor CRTL C<environ> values; they are set to the empty string.)An element of the CRTL C<environ> array can be set only if yourcopy of Perl knows about the CRTL's C<setenv()> function.  (This ispresent only in some versions of the DECCRTL; check C<$Config{d_setenv}>to see whether your copy of Perl was built with a CRTL that has thisfunction.)When an element of C<%ENV> is set to C<undef>,the element is looked up as if it were being read, and if it isfound, it is deleted.  (An item "deleted" from the CRTL C<environ>array is set to the empty string; this can only be done if yourcopy of Perl knows about the CRTL C<setenv()> function.)  UsingC<delete> to remove an element from C<%ENV> 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 PERL_ENV_TABLESis altered.  It is not possible at present to define a search listlogical name via %ENV.The element C<$ENV{DEFAULT}> is special: when read, it returnsPerl's current default device and directory, and when set, itresets them, regardless of the definition of F<PERL_ENV_TABLES>.It cannot be cleared or deleted; attempts to do so are silentlyignored.Note 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 "promote" them to logical names in the currentprocess, which will then be inherited by all subprocesses,by saying    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    }(You can't just say C<$ENV{$key} = $ENV{$key}>, since thePerl optimizer is smart enough to elide the expression.)Don't try to clear C<%ENV> by saying C<%ENV = ();>, it will throwa fatal error.  This is equivalent to doing the following from DCL:    DELETE/LOGICAL *You can imagine how bad things would be if, for example, the SYS$MANAGERor SYS$SYSTEM logicals were deleted.At present, the first time you iterate over %ENV usingC<keys>, or C<values>,  you will incur a time penalty as alllogical names are read, in order to fully populate %ENV.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.You do need to be careful with the logicals representing process-permanentfiles, such as C<SYS$INPUT> and C<SYS$OUTPUT>.  The translations for theselogicals are prepended with a two-byte binary value (0x1B 0x00) that needs to bestripped off if you want to use it. (In previous versions of Perl it wasn'tpossible to get the values of these logicals, as the null byte acted as anend-of-string marker)=item $!The string value of C<$!> is that returned by the CRTL'sstrerror() function, so it will include the VMS message forVMS-specific errors.  The numeric value of C<$!> is thevalue of C<errno>, except if errno is EVMSERR, in whichcase C<$!> contains the value of vaxc$errno.  Setting C<$!>always sets errno to the value specified.  If this value isEVMSERR, it also sets vaxc$errno to 4 (NONAME-F-NOMSG), sothat the string value of C<$!> won't reflect the VMS errormessage from before C<$!> was set.=item $^EThis variable provides direct access to VMS status valuesin vaxc$errno, which are often more specific than thegeneric Unix-style error messages in C<$!>.  Its numeric valueis the value of vaxc$errno, and its string value is thecorresponding VMS message string, as retrieved by sys$getmsg().Setting C<$^E> sets vaxc$errno to the value specified.=item $?The "status value" returned in C<$?> is synthesized from theactual exit status of the subprocess in a way that approximatesPOSIX wait(5) semantics, in order to allow Perl programs toportably test for successful completion of subprocesses.  Thelow order 8 bits of C<$?> are always 0 under VMS, since thetermination status of a process may or may not have beengenerated by an exception.  The next 8 bits are derived fromthe severity portion of the subprocess' exit status: if theseverity was success or informational, these bits are all 0;otherwise, they contain the severity value shifted left one bit.As a result, C<$?> will always be zero if the subprocess' exitstatus indicated successful completion, and non-zero if awarning or error occurred.  The actual VMS exit status maybe found in C<$^S> (q.v.).=item $^SUnder VMS, this is the 32-bit VMS status value returned by thelast subprocess to complete.  Unlike C<$?>, no manipulationis done to make this look like a POSIX wait(5) value, so itmay be treated as a normal VMS status value.=item $|Setting C<$|> for an I/O stream causes data to be flushedall the way to disk on each write (I<i.e.> not just tothe underlying RMS buffers for a file).  In other words,it's equivalent to calling fflush() and fsync() from C.=back=head1 Standard modules with VMS-specific differences=head2 SDBM_FileSDBM_File works properly on VMS. It has, however, one minordifference. The database directory file created has a F<.sdbm_dir>extension rather than a F<.dir> extension. F<.dir> files are VMS filesystemdirectory files, and using them for other purposes could cause unacceptableproblems.=head1 Revision dateThis document was last updated on 26-Feb-2000, for Perl 5, patchlevel 6.=head1 AUTHORCharles Bailey  <bailey@cor.newman.upenn.edu>Dan Sugalski  <dan@sidhe.org>

⌨️ 快捷键说明

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