perlvms.pod
来自「MSYS在windows下模拟了一个类unix的终端」· POD 代码 · 共 886 行 · 第 1/3 页
POD
886 行
=back=head1 Perl functionsAs of the time this document was last revised, the following Perl functions were implemented in the VMS port of Perl (functions marked with * are discussed in more detail below): file tests*, abs, alarm, atan, backticks*, binmode*, bless, caller, chdir, chmod, chown, chomp, chop, chr, close, closedir, cos, crypt*, defined, delete, die, do, dump*, each, endpwent, eof, eval, exec*, exists, exit, exp, fileno, fork*, getc, getlogin, getpwent*, getpwnam*, getpwuid*, glob, gmtime*, goto, grep, hex, import, index, int, join, keys, kill*, last, lc, lcfirst, length, local, localtime, log, m//, map, mkdir, my, next, no, oct, open, opendir, ord, pack, pipe, pop, pos, print, printf, push, q//, qq//, qw//, qx//*, quotemeta, rand, read, readdir, redo, ref, rename, require, reset, return, reverse, rewinddir, rindex, rmdir, s///, scalar, seek, seekdir, select(internal), select (system call)*, setpwent, shift, sin, sleep, sort, splice, split, sprintf, sqrt, srand, stat, study, substr, sysread, system*, syswrite, tell, telldir, tie, time, times*, tr///, uc, ucfirst, umask, undef, unlink*, unpack, untie, unshift, use, utime*, values, vec, wait, waitpid*, wantarray, warn, write, y///The following functions were not implemented in the VMS port, and calling them produces a fatal error (usually) or undefined behavior (rarely, we hope): chroot, dbmclose, dbmopen, fcntl, flock, getpgrp, getppid, getpriority, getgrent, getgrgid, getgrnam, setgrent, endgrent, ioctl, link, lstat, msgctl, msgget, msgsend, msgrcv, readlink, semctl, semget, semop, setpgrp, setpriority, shmctl, shmget, shmread, shmwrite, socketpair, symlink, syscallThe following functions are available on Perls compiled with Dec C 5.2 orgreater and running VMS 7.0 or greater truncateThe following functions may or may not be implemented, depending on what type of socket support you've built into your copy of Perl: accept, bind, connect, getpeername, gethostbyname, getnetbyname, getprotobyname, getservbyname, gethostbyaddr, getnetbyaddr, getprotobynumber, getservbyport, gethostent, getnetent, getprotoent, getservent, sethostent, setnetent, setprotoent, setservent, endhostent, endnetent, endprotoent, endservent, getsockname, getsockopt, listen, recv, select(system call)*, send, setsockopt, shutdown, socket=over 4=item File testsThe tests C<-b>, C<-B>, C<-c>, C<-C>, C<-d>, C<-e>, C<-f>,C<-o>, C<-M>, C<-s>, C<-S>, C<-t>, C<-T>, and C<-z> work asadvertised. The return values for C<-r>, C<-w>, and C<-x>tell you whether you can actually access the file; this maynot reflect the UIC-based file protections. Since real andeffective UIC don't differ under VMS, C<-O>, C<-R>, C<-W>,and C<-X> are equivalent to C<-o>, C<-r>, C<-w>, and C<-x>.Similarly, several other tests, including C<-A>, C<-g>, C<-k>,C<-l>, C<-p>, and C<-u>, aren't particularly meaningful underVMS, and the values returned by these tests reflect whateveryour CRTL C<stat()> routine does to the equivalent bits in thest_mode field. Finally, C<-d> returns true if passed a devicespecification without an explicit directory (e.g. C<DUA1:>), aswell as if passed a directory.Note: Some sites have reported problems when using the file-accesstests (C<-r>, C<-w>, and C<-x>) on files accessed via DEC's DFS.Specifically, since DFS does not currently provide access to theextended file header of files on remote volumes, attempts toexamine the ACL fail, and the file tests will return false,with C<$!> indicating that the file does not exist. You canuse C<stat> on these files, since that checks UIC-based protectiononly, and then manually check the appropriate bits, as defined byyour C compiler's F<stat.h>, in the mode value it returns, if youneed an approximation of the file's protections.=item backticksBackticks create a subprocess, and pass the enclosed stringto it for execution as a DCL command. Since the subprocess iscreated directly via C<lib$spawn()>, any valid DCL command stringmay be specified.=item binmode FILEHANDLEThe C<binmode> operator will attempt to insure that no translationof carriage control occurs on input from or output to this filehandle.Since this involves reopening the file and then restoring itsfile position indicator, if this function returns FALSE, theunderlying filehandle may no longer point to an open file, or maypoint to a different position in the file than before C<binmode>was called.Note that C<binmode> is generally not necessary when using normalfilehandles; it is provided so that you can control I/O to existingrecord-structured files when necessary. You can also use theC<vmsfopen> function in the VMS::Stdio extension to gain finercontrol of I/O to files and devices with different record structures.=item crypt PLAINTEXT, USERThe C<crypt> operator uses the C<sys$hash_password> systemservice to generate the hashed representation of PLAINTEXT.If USER is a valid username, the algorithm and salt valuesare taken from that user's UAF record. If it is not, thenthe preferred algorithm and a salt of 0 are used. Thequadword encrypted value is returned as an 8-character string.The value returned by C<crypt> may be compared againstthe encrypted password from the UAF returned by the C<getpw*>functions, in order to authenticate users. If you'regoing to do this, remember that the encrypted password inthe UAF was generated using uppercase username andpassword strings; you'll have to upcase the arguments toC<crypt> to insure that you'll get the proper value: sub validate_passwd { my($user,$passwd) = @_; my($pwdhash); if ( !($pwdhash = (getpwnam($user))[1]) || $pwdhash ne crypt("\U$passwd","\U$name") ) { intruder_alert($name); } return 1; }=item dumpRather than causing Perl to abort and dump core, the C<dump>operator invokes the VMS debugger. If you continue toexecute the Perl program under the debugger, control willbe transferred to the label specified as the argument toC<dump>, or, if no label was specified, back to thebeginning of the program. All other state of the program(I<e.g.> values of variables, open file handles) are notaffected by calling C<dump>.=item exec LISTThe C<exec> operator behaves in one of two different ways. If called after a call to C<fork>, it will invoke the CRTL C<execv()> routine, passing its arguments to the subprocess created by C<fork> for execution. In this case, it is subject to all limitations that affect C<execv()>. (In particular, this usually means that the command executed in the subprocess must be an image compiled from C source code, and that your options for passing file descriptors and signal handlers to the subprocess are limited.)If the call to C<exec> does not follow a call to C<fork>, it will cause Perl to exit, and to invoke the command given as an argument to C<exec> via C<lib$do_command>. If the argument begins with '@' or '$' (other than as part of a filespec), then it is executed as a DCL command. Otherwise, the first token on the command line is treated as the filespec of an image to run, and an attempt is made to invoke it (using F<.Exe> and the process defaults to expand the filespec) and pass the rest of C<exec>'s argument to it as parameters. If the tokenhas no file type, and matches a file with null type, then anattempt is made to determine whether the file is an executableimage which should be invoked using C<MCR> or a text file whichshould be passed to DCL as a command procedure.You can use C<exec> in both ways within the same script, as long as you call C<fork> and C<exec> in pairs. Perlkeeps track of how many times C<fork> and C<exec> have beencalled, and will call the CRTL C<execv()> routine if there havepreviously been more calls to C<fork> than to C<exec>.=item forkThe C<fork> operator works in the same way as the CRTL C<vfork()> routine, which is quite different under VMS than under Unix. Specifically, while C<fork> returns 0 after it is called and the subprocess PID after C<exec> is called, in both cases the thread of execution is within the parent process, so there is no opportunity to perform operations in the subprocess before calling C<exec>.In general, the use of C<fork> and C<exec> to create subprocess is not recommended under VMS; wherever possible, use the C<system> operator or piped filehandles instead.=item getpwent=item getpwnam=item getpwuidThese operators obtain the information described in L<perlfunc>,if you have the privileges necessary to retrieve the named user'sUAF information via C<sys$getuai>. If not, then only the C<$name>,C<$uid>, and C<$gid> items are returned. The C<$dir> item containsthe login directory in VMS syntax, while the C<$comment> itemcontains the login directory in Unix syntax. The C<$gcos> itemcontains the owner field from the UAF record. The C<$quota>item is not used.=item gmtimeThe C<gmtime> operator will function properly if you have aworking CRTL C<gmtime()> routine, or if the logical nameSYS$TIMEZONE_DIFFERENTIAL is defined as the number of secondswhich must be added to UTC to yield local time. (This logicalname is defined automatically if you are running a version ofVMS with built-in UTC support.) If neither of these cases istrue, a warning message is printed, and C<undef> is returned.=item killIn most cases, C<kill> is implemented via the CRTL's C<kill()>function, so it will behave according to that function'sdocumentation. If you send a SIGKILL, however, the $DELPRC systemservice is called directly. This insures that the targetprocess is actually deleted, if at all possible. (The CRTL's C<kill()>function is presently implemented via $FORCEX, which is ignored bysupervisor-mode images like DCL.)Also, negative signal values don't do anything special underVMS; they're just converted to the corresponding positive value.=item qx//See the entry on C<backticks> above.=item select (system call)If Perl was not built with socket support, the system callversion of C<select> is not available at all. If socketsupport is present, then the system call version ofC<select> functions only for file descriptors attachedto sockets. It will not provide information about regularfiles or pipes, since the CRTL C<select()> routine does notprovide this functionality.=item stat EXPRSince VMS keeps track of files according to a different schemethan Unix, it's not really possible to represent the file's IDin the C<st_dev> and C<st_ino> fields of a C<struct stat>. Perltries its best, though, and the values it uses are pretty unlikelyto be the same for two different files. We can't guarantee this,though, so caveat scriptor.=item system LISTThe C<system> operator creates a subprocess, and passes its arguments to the subprocess for execution as a DCL command. Since the subprocess is created directly via C<lib$spawn()>, any valid DCL command string may be specified. If the string begins with'@', it is treated as a DCL command unconditionally. Otherwise, ifthe first token contains a character used as a delimiter in filespecification (e.g. C<:> or C<]>), an attempt is made to expand itusing a default type of F<.Exe> and the process defaults, and ifsuccessful, the resulting file is invoked via C<MCR>. This allows youto invoke an image directly simply by passing the file specificationto C<system>, a common Unixish idiom. If the token has no file type,and matches a file with null type, then an attempt is made todetermine whether the file is an executable image which should beinvoked using C<MCR> or a text file which should be passed to DCLas a command procedure.If LIST consists of the empty string, C<system> spawns aninteractive DCL subprocess, in the same fashion as typingB<SPAWN> at the DCL prompt.Perl waits for the subprocess to complete before continuingexecution in the current process. As described in L<perlfunc>,the return value of C<system> is a fake "status" which followsPOSIX semantics; see the description of C<$?> in this documentfor more detail. The actual VMS exit status of the subprocessis available in C<$^S> (as long as you haven't used another Perlfunction that resets C<$?> and C<$^S> in the meantime).=item timeThe value returned by C<time> is the offset in seconds from01-JAN-1970 00:00:00 (just like the CRTL's times() routine), in orderto make life easier for code coming in from the POSIX/Unix world.=item timesThe array returned by the C<times> operator is divided up according to the same rules the CRTL C<times()> routine.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?