📄 perlwin32.1
字号:
programs. They consider it the application's job to handle that.This is commonly achieved by linking the application (in our case,perl) with startup code that the C runtime libraries usually provide.However, doing that results in incompatible perl versions (since thebehavior of the argv expansion code differs depending on thecompiler, and it is even buggy on some compilers). Besides, it maybe a source of frustration if you use such a perl binary with analternate shell that *does* expand wildcards..SpInstead, the following solution works rather well. The nice thingsabout it are 1) you can start using it right away; 2) it is morepowerful, because it will do the right thing with a pattern like*/*/*.c; 3) you can decide whether you do/don't want to use it; and4) you can extend the method to add any customizations (or evenentirely different kinds of wildcard expansion)..Sp.Vb 10\& C:\e> copy con c:\eperl\elib\eWild.pm\& # Wild.pm \- emulate shell @ARGV expansion on shells that don\*(Aqt\& use File::DosGlob;\& @ARGV = map {\& my @g = File::DosGlob::glob($_) if /[*?]/;\& @g ? @g : $_;\& } @ARGV;\& 1;\& ^Z\& C:\e> set PERL5OPT=\-MWild\& C:\e> perl \-le "for (@ARGV) { print }" */*/perl*.c\& p4view/perl/perl.c\& p4view/perl/perlio.c\& p4view/perl/perly.c\& perl5.005/win32/perlglob.c\& perl5.005/win32/perllib.c\& perl5.005/win32/perlglob.c\& perl5.005/win32/perllib.c\& perl5.005/win32/perlglob.c\& perl5.005/win32/perllib.c.Ve.SpNote there are two distinct steps there: 1) You'll have to createWild.pm and put it in your perl lib directory. 2) You'll need toset the \s-1PERL5OPT\s0 environment variable. If you want argv expansionto be the default, just set \s-1PERL5OPT\s0 in your default startupenvironment..SpIf you are using the Visual C compiler, you can get the C runtime'scommand line wildcard expansion built into perl binary. The resultingbinary will always expand unquoted command lines, which may not bewhat you want if you use a shell that does that for you. The expansiondone is also somewhat less powerful than the approach suggested above..IP "Win32 Specific Extensions" 4.IX Item "Win32 Specific Extensions"A number of extensions specific to the Win32 platform are availablefrom \s-1CPAN\s0. You may find that many of these extensions are meant tobe used under the Activeware port of Perl, which used to be the onlynative port for the Win32 platform. Since the Activeware port does nothave adequate support for Perl's extension building tools, theseextensions typically do not support those tools either and, therefore,cannot be built using the generic steps shown in the previous section..SpTo ensure smooth transitioning of existing code that uses theActiveState port, there is a bundle of Win32 extensions that containsall of the ActiveState extensions and several other Win32 extensions from\&\s-1CPAN\s0 in source form, along with many added bugfixes, and with MakeMakersupport. The latest version of this bundle is available at:.Sp.Vb 1\& http://search.cpan.org/dist/libwin32/.Ve.SpSee the \s-1README\s0 in that distribution for building and installationinstructions..IP "Notes on 64\-bit Windows" 4.IX Item "Notes on 64-bit Windows"Windows .NET Server supports the \s-1LLP64\s0 data model on the Intel Itaniumarchitecture..SpThe \s-1LLP64\s0 data model is different from the \s-1LP64\s0 data model that is thenorm on 64\-bit Unix platforms. In the former, \f(CW\*(C`int\*(C'\fR and \f(CW\*(C`long\*(C'\fR areboth 32\-bit data types, while pointers are 64 bits wide. In addition,there is a separate 64\-bit wide integral type, \f(CW\*(C`_\|_int64\*(C'\fR. In contrast,the \s-1LP64\s0 data model that is pervasive on Unix platforms provides \f(CW\*(C`int\*(C'\fRas the 32\-bit type, while both the \f(CW\*(C`long\*(C'\fR type and pointers are of64\-bit precision. Note that both models provide for 64\-bits ofaddressability..Sp64\-bit Windows running on Itanium is capable of running 32\-bit x86binaries transparently. This means that you could use a 32\-bit buildof Perl on a 64\-bit system. Given this, why would one want to builda 64\-bit build of Perl? Here are some reasons why you would bother:.RS 4.IP "\(bu" 4A 64\-bit native application will run much more efficiently onItanium hardware..IP "\(bu" 4There is no 2GB limit on process size..IP "\(bu" 4Perl automatically provides large file support when built under64\-bit Windows..IP "\(bu" 4Embedding Perl inside a 64\-bit application..RE.RS 4.RE.Sh "Running Perl Scripts".IX Subsection "Running Perl Scripts"Perl scripts on \s-1UNIX\s0 use the \*(L"#!\*(R" (a.k.a \*(L"shebang\*(R") line toindicate to the \s-1OS\s0 that it should execute the file using perl.Win32 has no comparable means to indicate arbitrary files areexecutables..PPInstead, all available methods to execute plain text files onWin32 rely on the file \*(L"extension\*(R". There are three methodsto use this to execute perl scripts:.IP "1." 8There is a facility called \*(L"file extension associations\*(R" that willwork in Windows \s-1NT\s0 4.0. This can be manipulated via the twocommands \*(L"assoc\*(R" and \*(L"ftype\*(R" that come standard with Windows \s-1NT\s04.0. Type \*(L"ftype /?\*(R" for a complete example of how to set thisup for perl scripts (Say what? You thought Windows \s-1NT\s0 wasn'tperl-ready? :)..IP "2." 8Since file associations don't work everywhere, and there arereportedly bugs with file associations where it does work, theold method of wrapping the perl script to make it look like aregular batch file to the \s-1OS\s0, may be used. The install processmakes available the \*(L"pl2bat.bat\*(R" script which can be used to wrapperl scripts into batch files. For example:.Sp.Vb 1\& pl2bat foo.pl.Ve.Spwill create the file \*(L"\s-1FOO\s0.BAT\*(R". Note \*(L"pl2bat\*(R" strips any\&.pl suffix and adds a .bat suffix to the generated file..SpIf you use the 4DOS/NT or similar command shell, note that\&\*(L"pl2bat\*(R" uses the \*(L"%*\*(R" variable in the generated batch file torefer to all the command line arguments, so you may need to makesure that construct works in batch files. As of this writing,4DOS/NT users will need a \*(L"ParameterChar = *\*(R" statement in their4NT.INI file or will need to execute \*(L"setdos /p*\*(R" in the 4DOS/NTstartup file to enable this to work..IP "3." 8Using \*(L"pl2bat\*(R" has a few problems: the file name gets changed,so scripts that rely on \f(CW$0\fR to find what they must do may notrun properly; running \*(L"pl2bat\*(R" replicates the contents of theoriginal script, and so this process can be maintenance intensiveif the originals get updated often. A different approach thatavoids both problems is possible..SpA script called \*(L"runperl.bat\*(R" is available that can be copiedto any filename (along with the .bat suffix). For example,if you call it \*(L"foo.bat\*(R", it will run the file \*(L"foo\*(R" when it isexecuted. Since you can run batch files on Win32 platforms simplyby typing the name (without the extension), this effectivelyruns the file \*(L"foo\*(R", when you type either \*(L"foo\*(R" or \*(L"foo.bat\*(R".With this method, \*(L"foo.bat\*(R" can even be in a different locationthan the file \*(L"foo\*(R", as long as \*(L"foo\*(R" is available somewhere onthe \s-1PATH\s0. If your scripts are on a filesystem that allows symboliclinks, you can even avoid copying \*(L"runperl.bat\*(R"..SpHere's a diversion: copy \*(L"runperl.bat\*(R" to \*(L"runperl\*(R", and type\&\*(L"runperl\*(R". Explain the observed behavior, or lack thereof. :)Hint: .gnidnats llits er'uoy fi ,\*(L"lrepnur\*(R" eteled :tniH.Sh "Miscellaneous Things".IX Subsection "Miscellaneous Things"A full set of \s-1HTML\s0 documentation is installed, so you should beable to use it if you have a web browser installed on yoursystem..PP\&\f(CW\*(C`perldoc\*(C'\fR is also a useful tool for browsing information containedin the documentation, especially in conjunction with a pagerlike \f(CW\*(C`less\*(C'\fR (recent versions of which have Win32 support). You mayhave to set the \s-1PAGER\s0 environment variable to use a specific pager.\&\*(L"perldoc \-f foo\*(R" will print information about the perl operator\&\*(L"foo\*(R"..PPOne common mistake when using this port with a \s-1GUI\s0 library like \f(CW\*(C`Tk\*(C'\fRis assuming that Perl's normal behavior of opening a command-linewindow will go away. This isn't the case. If you want to start a copyof \f(CW\*(C`perl\*(C'\fR without opening a command-line window, use the \f(CW\*(C`wperl\*(C'\fRexecutable built during the installation process. Usage is exactlythe same as normal \f(CW\*(C`perl\*(C'\fR on Win32, except that options like \f(CW\*(C`\-h\*(C'\fRdon't work (since they need a command-line window to print to)..PPIf you find bugs in perl, you can run \f(CW\*(C`perlbug\*(C'\fR to create abug report (you may have to send it manually if \f(CW\*(C`perlbug\*(C'\fR cannotfind a mailer on your system)..SH "BUGS AND CAVEATS".IX Header "BUGS AND CAVEATS"Norton AntiVirus interferes with the build process, particularly ifset to \*(L"AutoProtect, All Files, when Opened\*(R". Unlike large applicationsthe perl build process opens and modifies a lot of files. Having thethe AntiVirus scan each and every one slows build the process significantly.Worse, with PERLIO=stdio the build process fails with peculiar messagesas the virus checker interacts badly with miniperl.exe writing configurefiles (it seems to either catch file part written and treat it as suspicious,or virus checker may have it \*(L"locked\*(R" in a way which inhibits miniperlupdating it). The build does complete with.PP.Vb 1\& set PERLIO=perlio.Ve.PPbut that may be just luck. Other AntiVirus software may have similar issues..PPSome of the built-in functions do not act exactly as documented inperlfunc, and a few are not implemented at all. To avoidsurprises, particularly if you have had prior exposure to Perlin other operating environments or if you intend to write codethat will be portable to other environments, see perlportfor a reasonably definitive list of these differences..PPNot all extensions available from \s-1CPAN\s0 may build or work properlyin the Win32 environment. See \*(L"Building Extensions\*(R"..PPMost \f(CW\*(C`socket()\*(C'\fR related calls are supported, but they may notbehave as on Unix platforms. See perlport for the full list.Perl requires Winsock2 to be installed on the system. If you'rerunning Win95, you can download Winsock upgrade from here:.PPhttp://www.microsoft.com/windows95/downloads/contents/WUAdminTools/S_WUNetworkingTools/W95Sockets2/Default.asp.PPLater \s-1OS\s0 versions already include Winsock2 support..PPSignal handling may not behave as on Unix platforms (where itdoesn't exactly \*(L"behave\*(R", either :). For instance, calling \f(CW\*(C`die()\*(C'\fRor \f(CW\*(C`exit()\*(C'\fR from signal handlers will cause an exception, since mostimplementations of \f(CW\*(C`signal()\*(C'\fR on Win32 are severely crippled.Thus, signals may work only for simple things like setting a flagvariable in the handler. Using signals under this port shouldcurrently be considered unsupported..PPPlease send detailed descriptions of any problems and solutions thatyou may find to <\fIperlbug@perl.org\fR>, along with the outputproduced by \f(CW\*(C`perl \-V\*(C'\fR..SH "ACKNOWLEDGEMENTS".IX Header "ACKNOWLEDGEMENTS"The use of a camel with the topic of Perl is a trademarkof O'Reilly and Associates, Inc. Used with permission..SH "AUTHORS".IX Header "AUTHORS".IP "Gary Ng <71564.1743@CompuServe.COM>" 4.IX Item "Gary Ng <71564.1743@CompuServe.COM>".PD 0.IP "Gurusamy Sarathy <gsar@activestate.com>" 4.IX Item "Gurusamy Sarathy <gsar@activestate.com>".IP "Nick Ing-Simmons <nick@ing\-simmons.net>" 4.IX Item "Nick Ing-Simmons <nick@ing-simmons.net>".IP "Jan Dubois <jand@activestate.com>" 4.IX Item "Jan Dubois <jand@activestate.com>".IP "Steve Hay <steve.hay@uk.radan.com>" 4.IX Item "Steve Hay <steve.hay@uk.radan.com>".PD.PPThis document is maintained by Jan Dubois..SH "SEE ALSO".IX Header "SEE ALSO"perl.SH "HISTORY".IX Header "HISTORY"This port was originally contributed by Gary Ng around 5.003_24,and borrowed from the Hip Communications port that was availableat the time. Various people have made numerous and sundry hackssince then..PPBorland support was added in 5.004_01 (Gurusamy Sarathy)..PPGCC/mingw32 support was added in 5.005 (Nick Ing-Simmons)..PPSupport for \s-1PERL_OBJECT\s0 was added in 5.005 (ActiveState Tool Corp)..PPSupport for \fIfork()\fR emulation was added in 5.6 (ActiveState Tool Corp)..PPWin9x support was added in 5.6 (Benjamin Stuhl)..PPSupport for 64\-bit Windows added in 5.8 (ActiveState Corp)..PPLast updated: 29 August 2007
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -