perlvms.pod
来自「MSYS在windows下模拟了一个类unix的终端」· POD 代码 · 共 886 行 · 第 1/3 页
POD
886 行
=head1 NAMEperlvms - VMS-specific documentation for Perl=head1 DESCRIPTIONGathered below are notes describing details of Perl 5's behavior on VMS. They are a supplement to the regular Perl 5 documentation, so we have focussed on the ways in which Perl 5 functions differently under VMS than it does under Unix, and on the interactions between Perl and the rest of the operating system. We haven't tried to duplicate complete descriptions of Perl features from the main Perl documentation, which can be found in the F<[.pod]> subdirectory of the Perl distribution.We hope these notes will save you from confusion and lost sleep when writing Perl scripts on VMS. If you find we've missed something you think should appear here, please don't hesitate to drop a line to vmsperl@newman.upenn.edu.=head1 InstallationDirections for building and installing Perl 5 can be found in the file F<README.vms> in the main source directory of the Perl distribution..=head1 Organization of Perl Images=head2 Core ImagesDuring the installation process, three Perl images are produced.F<Miniperl.Exe> is an executable image which contains all ofthe basic functionality of Perl, but cannot take advantage ofPerl extensions. It is used to generate several files neededto build the complete Perl and various extensions. Once you'vefinished installing Perl, you can delete this image.Most of the complete Perl resides in the shareable imageF<PerlShr.Exe>, which provides a core to which the Perl executableimage and all Perl extensions are linked. You should place thisimage in F<Sys$Share>, or define the logical name F<PerlShr> totranslate to the full file specification of this image. It shouldbe world readable. (Remember that if a user has execute only accessto F<PerlShr>, VMS will treat it as if it were a privileged shareableimage, and will therefore require all downstream shareable images to beINSTALLed, etc.)Finally, F<Perl.Exe> is an executable image containing the mainentry point for Perl, as well as some initialization code. Itshould be placed in a public directory, and made world executable.In order to run Perl with command line arguments, you shoulddefine a foreign command to invoke this image.=head2 Perl ExtensionsPerl extensions are packages which provide both XS and Perl codeto add new functionality to perl. (XS is a meta-language whichsimplifies writing C code which interacts with Perl, seeL<perlxs> for more details.) The Perl code for anextension is treated like any other library module - it'smade available in your script through the appropriateC<use> or C<require> statement, and usually defines a Perlpackage containing the extension.The portion of the extension provided by the XS code may beconnected to the rest of Perl in either of two ways. In theB<static> configuration, the object code for the extension islinked directly into F<PerlShr.Exe>, and is initialized wheneverPerl is invoked. In the B<dynamic> configuration, the extension'smachine code is placed into a separate shareable image, which ismapped by Perl's DynaLoader when the extension is C<use>d orC<require>d in your script. This allows you to maintain theextension as a separate entity, at the cost of keeping track of theadditional shareable image. Most extensions can be set up as eitherstatic or dynamic.The source code for an extension usually resides in its owndirectory. At least three files are generally provided:I<Extshortname>F<.xs> (where I<Extshortname> is the portion ofthe extension's name following the last C<::>), containingthe XS code, I<Extshortname>F<.pm>, the Perl library modulefor the extension, and F<Makefile.PL>, a Perl script which usesthe C<MakeMaker> library modules supplied with Perl to generatea F<Descrip.MMS> file for the extension.=head2 Installing static extensionsSince static extensions are incorporated directly intoF<PerlShr.Exe>, you'll have to rebuild Perl to incorporate anew extension. You should edit the main F<Descrip.MMS> or F<Makefile>you use to build Perl, adding the extension's name to the C<ext>macro, and the extension's object file to the C<extobj> macro.You'll also need to build the extension's object file, eitherby adding dependencies to the main F<Descrip.MMS>, or using aseparate F<Descrip.MMS> for the extension. Then, rebuildF<PerlShr.Exe> to incorporate the new code.Finally, you'll need to copy the extension's Perl librarymodule to the F<[.>I<Extname>F<]> subdirectory under oneof the directories in C<@INC>, where I<Extname> is the nameof the extension, with all C<::> replaced by C<.> (e.g.the library module for extension Foo::Bar would be copiedto a F<[.Foo.Bar]> subdirectory).=head2 Installing dynamic extensionsIn general, the distributed kit for a Perl extension includesa file named Makefile.PL, which is a Perl program which is usedto create a F<Descrip.MMS> file which can be used to build andinstall the files required by the extension. The kit should beunpacked into a directory tree B<not> under the main Perl sourcedirectory, and the procedure for building the extension is simply $ perl Makefile.PL ! Create Descrip.MMS $ mmk ! Build necessary files $ mmk test ! Run test code, if supplied $ mmk install ! Install into public Perl treeI<N.B.> The procedure by which extensions are built andtested creates several levels (at least 4) under thedirectory in which the extension's source files live.For this reason, you shouldn't nest the source directorytoo deeply in your directory structure, lest you exceed RMS'maximum of 8 levels of subdirectory in a filespec. (Youcan use rooted logical names to get another 8 levels ofnesting, if you can't place the files near the top ofthe physical directory structure.)VMS support for this process in the current release of Perlis sufficient to handle most extensions. However, it doesnot yet recognize extra libraries required to build shareableimages which are part of an extension, so these must be addedto the linker options file for the extension by hand. Forinstance, if the F<PGPLOT> extension to Perl requires theF<PGPLOTSHR.EXE> shareable image in order to properly linkthe Perl extension, then the line C<PGPLOTSHR/Share> mustbe added to the linker options file F<PGPLOT.Opt> producedduring the build process for the Perl extension.By default, the shareable image for an extension is placedF<[.lib.site_perl.auto>I<Arch>.I<Extname>F<]> directory of theinstalled Perl directory tree (where I<Arch> is F<VMS_VAX> orF<VMS_AXP>, and I<Extname> is the name of the extension, witheach C<::> translated to C<.>). (See the MakeMaker documentationfor more details on installation options for extensions.)However, it can be manually placed in any of several locations: - the F<[.Lib.Auto.>I<Arch>I<$PVers>I<Extname>F<]> subdirectory of one of the directories in C<@INC> (where I<PVers> is the version of Perl you're using, as supplied in C<$]>, with '.' converted to '_'), or - one of the directories in C<@INC>, or - a directory which the extensions Perl library module passes to the DynaLoader when asking it to map the shareable image, or - F<Sys$Share> or F<Sys$Library>.If the shareable image isn't in any of these places, you'll needto define a logical name I<Extshortname>, where I<Extshortname>is the portion of the extension's name after the last C<::>, whichtranslates to the full file specification of the shareable image.=head1 File specifications=head2 SyntaxWe have tried to make Perl aware of both VMS-style and Unix-style file specifications wherever possible. You may use either style, or both, on the command line and in scripts, but you may not combine the two styles within a single file specification. VMS Perl interprets Unix pathnames in muchthe same way as the CRTL (I<e.g.> the first component ofan absolute path is read as the device name for theVMS file specification). There are a set of functionsprovided in the C<VMS::Filespec> package for explicitinterconversion between VMS and Unix syntax; itsdocumentation provides more details.Filenames are, of course, still case-insensitive. Forconsistency, most Perl routines return filespecs usinglower case letters only, regardless of the case used inthe arguments passed to them. (This is true only whenrunning under VMS; Perl respects the case-sensitivityof OSs like Unix.)We've tried to minimize the dependence of Perl library modules on Unix syntax, but you may find that some of these, as well as some scripts written for Unix systems, will require that you use Unix syntax, since they will assume that '/' is the directory separator, I<etc.> If you find instances of this in the Perl distribution itself, please let us know, so we can try to work around them. =head2 Wildcard expansionFile specifications containing wildcards are allowed both on the command line and within Perl globs (e.g. <CE<lt>*.cE<gt>>). Ifthe wildcard filespec uses VMS syntax, the resultant filespecs will follow VMS syntax; if a Unix-style filespec is passed in, Unix-style filespecs will be returned.In both cases, VMS wildcard expansion is performed. (csh-stylewildcard expansion is available if you use C<File::Glob::glob>.)If the wildcard filespec contains a device or directory specification, then the resultant filespecs will also contain a device and directory; otherwise, device and directory information are removed. VMS-style resultant filespecs will contain a full device and directory, while Unix-style resultant filespecs will contain only as much of a directory path as was present in the input filespec. For example, if your default directory is Perl_Root:[000000], the expansion of C<[.t]*.*> will yield filespecs like "perl_root:[t]base.dir", while the expansion of C<t/*/*> will yield filespecs like "t/base.dir". (This is done to match the behavior of glob expansion performed by Unix shells.) Similarly, the resultant filespec will contain the file versiononly if one was present in the input filespec.=head2 PipesInput and output pipes to Perl filehandles are supported; the "file name" is passed to lib$spawn() for asynchronous execution. You should be careful to close any pipes you have opened in a Perl script, lest you leave any "orphaned" subprocesses around when Perl exits. You may also use backticks to invoke a DCL subprocess, whose output is used as the return value of the expression. The string between the backticks is handled as if it were theargument to the C<system> operator (see below). In this case,Perl will wait for the subprocess to complete before continuing. =head1 PERL5LIB and PERLLIBThe PERL5LIB and PERLLIB logical names work as documented in L<perl>,except that the element separator is '|' instead of ':'. Thedirectory specifications may use either VMS or Unix syntax.=head1 Command line=head2 I/O redirection and backgroundingPerl for VMS supports redirection of input and output on the command line, using a subset of Bourne shell syntax: <F<file> reads stdin from F<file>, >F<file> writes stdout to F<file>, >>F<file> appends stdout to F<file>, 2>F<file> writes stderr to F<file>, and 2>>F<file> appends stderr to F<file>. In addition, output may be piped to a subprocess, using the character '|'. Anything after this character on the command line is passed to a subprocess for execution; the subprocess takes the output of Perl as its input.Finally, if the command line ends with '&', the entire command is run in the background as an asynchronous subprocess.=head2 Command line switchesThe following command line switches behave differently underVMS than described in L<perlrun>. Note also that in orderto pass uppercase switches to Perl, you need to enclosethem in double-quotes on the command line, since the CRTLdowncases all unquoted strings.=over 4=item -iIf the C<-i> switch is present but no extension for a backupcopy is given, then inplace editing creates a new version ofa file; the existing copy is not deleted. (Note that ifan extension is given, an existing file is renamed to the backupfile, as is the case under other operating systems, so it doesnot remain as a previous version under the original filename.)=item -SIf the C<-S> switch is present I<and> the script name doesnot contain a directory, then Perl translates the logicalname DCL$PATH as a searchlist, using each translation asa directory in which to look for the script. In addition,if no file type is specified, Perl looks in each directoryfor a file matching the name specified, with a blank type,a type of F<.pl>, and a type of F<.com>, in that order.=item -uThe C<-u> switch causes the VMS debugger to be invokedafter the Perl program is compiled, but before it hasrun. It does not create a core dump file.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?