Debian Codegraph @

upstream/debian-unstable/man1/perlwin32.1

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "PERLWIN32 1"
58 .TH PERLWIN32 1 2025-11-16 "perl v5.40.1" "Perl Programmers Reference Guide"
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 perlwin32 \- Perl under Windows
65 .SH SYNOPSIS
66 .IX Header "SYNOPSIS"
67 These are instructions for building Perl under Windows 7 and later.
68 .SH DESCRIPTION
69 .IX Header "DESCRIPTION"
70 Before you start, you should glance through the README file
71 found in the top-level directory to which the Perl distribution
72 was extracted. Make sure you read and understand the terms under
73 which this software is being distributed.
74 .PP
75 Also make sure you read "BUGS AND CAVEATS" below for the
76 known limitations of this port.
77 .PP
78 The INSTALL file in the perl top-level has much information that is
79 only relevant to people building Perl on Unix-like systems. In
80 particular, you can safely ignore any information that talks about
81 "Configure".
82 .PP
83 You may also want to look at one other option for building a perl that
84 will work on Windows: the README.cygwin file, which give a different
85 set of rules to build a perl for Windows. This method will probably
86 enable you to build a more Unix-compatible perl, but you will also
87 need to download and use various other build-time and run-time support
88 software described in that file.
89 .PP
90 This set of instructions is meant to describe a so-called "native"
91 port of Perl to the Windows platform. This includes both 32\-bit and
92 64\-bit Windows operating systems. The resulting Perl requires no
93 additional software to run (other than what came with your operating
94 system). Currently, this port is capable of using one of the
95 following compilers on the Intel x86 and x86_64 architectures:
96 .PP
97 .Vb 4
98 \& Microsoft Visual C++ Visual C++ 2015 (version 14.0) or later
99 \& Intel C++ Compiler (experimental)
100 \& Gcc by mingw.org gcc version 3.4.5\-5.3.0
101 \& Gcc by mingw\-w64.org gcc version 4.4.3 or later
102 .Ve
103 .PP
104 Note that the last two of these are actually competing projects both
105 delivering complete gcc toolchain for MS Windows:
106 .IP <https://osdn.net/projects/mingw/> 4
107 .IX Item "<https://osdn.net/projects/mingw/>"
108 Delivers gcc toolchain building 32\-bit executables (which can be used both 32 and 64 bit Windows platforms)
109 .IP <https://mingw\-w64.org> 4
110 .IX Item "<https://mingw-w64.org>"
111 Delivers gcc toolchain targeting both 64\-bit Windows and 32\-bit Windows
112 platforms (despite the project name "mingw\-w64" they are not only 64\-bit
113 oriented). They deliver the native gcc compilers and cross-compilers
114 that are also supported by perl's makefile.
115 .PP
116 The Microsoft Visual C++ compilers are also now being given away free. They
117 are available as "Visual C++ 2015\-2022 Community Edition" and are the same
118 compilers that ship with "Visual C++ 2015\-2022 Professional".
119 .PP
120 The MinGW64 compiler is available at <https://mingw\-w64.org>.
121 The latter is actually a cross-compiler targeting Win64. There's also a trimmed
122 down compiler (no java, or gfortran) suitable for building perl available at:
123 <https://strawberryperl.com/package/kmx/64_gcctoolchain/>
124 .PP
125 NOTE: If you're using a 32\-bit compiler to build perl on a 64\-bit Windows
126 operating system, then you should set the WIN64 environment variable to "undef".
127 Also, the trimmed down compiler only passes tests when USE_ITHREADS *= define
128 (as opposed to undef) and when the CFG *= Debug line is commented out.
129 .PP
130 This port fully supports MakeMaker (the set of modules that
131 is used to build extensions to perl). Therefore, you should be
132 able to build and install most extensions found in the CPAN sites.
133 See "Usage Hints for Perl on Windows" below for general hints about this.
134 .SS "Setting Up Perl on Windows"
135 .IX Subsection "Setting Up Perl on Windows"
136 .IP Make 4
137 .IX Item "Make"
138 You need a "make" program to build the sources. If you are using
139 Visual C++, you can use nmake supplied with Visual C++.
140 You may also use gmake instead of nmake. Builds using gcc need
141 gmake. nmake is not supported for gcc builds. Parallel building is only
142 supported with gmake, not nmake.
143 .IP "Command Shell" 4
144 .IX Item "Command Shell"
145 Use the default "cmd" shell that comes with Windows. Some versions of the
146 popular 4DOS/NT shell have incompatibilities that may cause you trouble.
147 If the build fails under that shell, try building again with the cmd
148 shell.
149 .Sp
150 Make sure the path to the build directory does not contain spaces. The
151 build usually works in this circumstance, but some tests will fail.
152 .IP "Microsoft Visual C++" 4
153 .IX Item "Microsoft Visual C++"
154 The nmake that comes with Visual C++ will suffice for building. Visual C++
155 requires that certain things be set up in the console before Visual C++ will
156 successfully run. To make a console box be able to run the C compiler, you will
157 need to beforehand, run \f(CW\*(C`vcvarsall.bat x86\*(C'\fR to compile for x86\-32 and for
158 x86\-64 \f(CW\*(C`vcvarsall.bat amd64\*(C'\fR. On a typical install of a Microsoft C++
159 compiler product, these batch files will already be in your \f(CW\*(C`PATH\*(C'\fR
160 environment variable so you may just type them without an absolute path into
161 your console. If you need to find the absolute path to the batch file, it is
162 usually found somewhere like
163 C:\eProgram Files (x86)\eMicrosoft Visual Studio 14.0\eVC.
164 With some newer Microsoft C products (released after ~2004), the installer will
165 put a shortcut in the start menu to launch a new console window with the
166 console already set up for your target architecture (x86\-32 or x86\-64 or IA64).
167 With the newer compilers, you may also use the older batch files if you choose
168 so.
169 .IP "Microsoft Visual C++ 2015\-2022 Community Edition" 4
170 .IX Item "Microsoft Visual C++ 2015-2022 Community Edition"
171 These free versions of Visual C++ 2015\-2022 Professional contain the same
172 compilers and linkers that ship with the full versions, and also contain
173 everything necessary to build Perl.
174 .Sp
175 These packages can be downloaded from <https://visualstudio.microsoft.com/>.
176 .Sp
177 Install Visual C++ 2015\-2022 Community, then setup your environment
178 using, e.g.
179 .Sp
180 \&\fIC:\eProgram Files\eMicrosoft Visual Studio 14.0\eCommon7\eTools\evsvars32.bat\fR
181 .Sp
182 (assuming the default installation location was chosen).
183 .Sp
184 Perl should now build using the \fIwin32/Makefile\fR. You will need to edit that
185 file to set \f(CW\*(C`CCTYPE\*(C'\fR to one of \f(CW\*(C`MSVC140\*(C'\fR\-\f(CW\*(C`MSVC143\*(C'\fR first.
186 .IP "Microsoft C++ Build Tools" 4
187 .IX Item "Microsoft C++ Build Tools"
188 There's also a standalone (IDE-less) version of the build tools mentioned
189 above containing the MSVC compiler available for download from
190 <https://visualstudio.microsoft.com/visual\-cpp\-build\-tools/>.
191 .Sp
192 This is also referred to as \fIBuild Tools for Visual Studio\fR.
193 .IP GCC 4
194 .IX Item "GCC"
195 Perl can be compiled with gcc from MinGW (version 3.4.5 or later) or from
196 MinGW64 (version 4.4.3 or later). It can be downloaded here:
197 .Sp
198 <https://osdn.net/projects/mingw/>
199 <https://www.mingw\-w64.org/>
200 .Sp
201 You also need gmake. Usually it comes with MinGW but its executable may have
202 a different name, such as mingw32\-make.exe.
203 .Sp
204 Note that the MinGW build currently fails with version 6.3.0 or later.
205 .Sp
206 Note also that the C++ mode build currently fails with MinGW 3.4.5 and 4.7.2
207 or later, and with MinGW64 64\-bit 6.3.0 or later.
208 .IP "Intel C++ Compiler" 4
209 .IX Item "Intel C++ Compiler"
210 Experimental support for using Intel C++ Compiler has been added. Edit
211 \&\fIwin32/Makefile\fR and pick the correct \f(CW\*(C`CCTYPE\*(C'\fR for the Visual C that Intel C
212 was installed into. Also uncomment \f(CW\*(C`_\|_ICC\*(C'\fR to enable Intel C on Visual C support.
213 To set up the build environment, from the Start Menu run
214 IA\-32 Visual Studio 20_\|_ mode or Intel 64 Visual Studio 20_\|_ mode as
215 appropriate. Then run \f(CW\*(C`nmake\*(C'\fR as usual in that prompt box.
216 .Sp
217 Only Intel C++ Compiler v12.1 has been tested. Other versions probably will
218 work. Using Intel C++ Compiler instead of Visual C has the benefit of C99
219 compatibility which is needed by some CPAN XS modules, while maintaining
220 compatibility with Visual C object code and Visual C debugging infrastructure
221 unlike GCC.
222 .SS Building
223 .IX Subsection "Building"
224 .IP \(bu 4
225 Make sure you are in the \fIwin32\fR subdirectory under the perl toplevel.
226 This directory contains a \fIMakefile\fR that will work with
227 versions of \f(CW\*(C`nmake\*(C'\fR that come with Visual C++, and
228 a GNU make \fIGNUmakefile\fR that will work for all supported compilers.
229 The defaults in the \f(CW\*(C`gmake\*(C'\fR makefile are set up to build with MinGW/gcc.
230 .IP \(bu 4
231 Edit the \fIGNUmakefile\fR (or \fIMakefile\fR, if you're using \fInmake\fR) and change
232 the values of \fIINST_DRV\fR and \f(CW\*(C`INST_TOP\*(C'\fR. You can also enable various build
233 flags. These are explained in the makefiles.
234 .Sp
235 Note that it is generally not a good idea to try to build a \f(CW\*(C`perl\*(C'\fR with
236 \&\f(CW\*(C`INST_DRV\*(C'\fR and \f(CW\*(C`INST_TOP\*(C'\fR set to a path that already exists from a previous
237 build. In particular, this may cause problems with the
238 \&\fIlib/ExtUtils/t/Embed.t\fR test, which attempts to build a test program and
239 may end up building against the installed \f(CW\*(C`perl\*(C'\fR's \fIlib/CORE\fR directory
240 rather than the one being tested.
241 .Sp
242 You will have to make sure that \f(CW\*(C`CCTYPE\*(C'\fR is set correctly and that
243 \&\f(CW\*(C`CCHOME\*(C'\fR points to wherever you installed your compiler. For GCC this
244 should be the directory that contains the \fIbin\fR, \fIinclude\fR and
245 \&\fIlib\fR directories.
246 .Sp
247 If building with the cross-compiler provided by
248 mingw\-w64.org you'll need to uncomment the line that sets
249 \&\f(CW\*(C`GCCCROSS\*(C'\fR in the \fIGNUmakefile\fR. Do this only if it's the cross-compiler,
250 ie. only if the \fIbin\fR folder doesn't contain a \fIgcc.exe\fR. (The cross-compiler
251 does not provide a \fIgcc.exe\fR, \fIg++.exe\fR, \fIar.exe\fR, etc. Instead, all of these
252 executables are prefixed with \f(CW\*(C`x86_64\-w64\-mingw32\-\*(C'\fR.)
253 .Sp
254 The default value for \f(CW\*(C`CCHOME\*(C'\fR in the makefiles for Visual C++
255 may not be correct for some versions. Make sure the default exists
256 and is valid.
257 .Sp
258 If you want build some core extensions statically into \f(CW\*(C`perl\*(C'\fR's DLL,
259 specify them in the \f(CW\*(C`STATIC_EXT\*(C'\fR macro.
260 .Sp
261 Be sure to read the instructions near the top of the makefiles carefully.
262 .IP \(bu 4
263 Type \f(CW\*(C`gmake\*(C'\fR (or \f(CW\*(C`nmake\*(C'\fR if you are using that version of \f(CW\*(C`make\*(C'\fR).
264 .Sp
265 This should build everything. Specifically, it will create \fIperl.exe\fR,
266 \&\fIperl540.dll\fR at the perl toplevel, and various other extension DLL's
267 under the \fIlib\eauto\fR directory. If the build fails for any reason, make
268 sure you have done the previous steps correctly.
269 .Sp
270 To try \f(CW\*(C`gmake\*(C'\fR's parallel mode, type \f(CW\*(C`gmake \-j2\*(C'\fR where \f(CW2\fR is the maximum number
271 of parallel jobs you want to run. A number of things in the build process will
272 run in parallel, but there are serialization points where you will see just 1
273 CPU maxed out. This is normal.
274 .Sp
275 If you are advanced enough with building C code, here is a suggestion to speed
276 up building \f(CW\*(C`perl\*(C'\fR, and the later \f(CW\*(C`make test\*(C'\fR. Try to keep your \f(CW\*(C`PATH\*(C'\fR environment
277 variable with the least number of folders possible (remember to keep your C
278 compiler's folders there). \fIC:\eWINDOWS\esystem32\fR or \fIC:\eWINNT\esystem32\fR
279 depending on your OS version should be first folder in \f(CW\*(C`PATH\*(C'\fR, since \f(CW\*(C`cmd.exe\*(C'\fR
280 is the most commonly launched program during the build and later testing.
281 .SS "Testing Perl on Windows"
282 .IX Subsection "Testing Perl on Windows"
283 Type "gmake test" (or "nmake test"). This will run most
284 of the tests from the testsuite (many tests will be skipped).
285 .PP
286 There should be no test failures.
287 .PP
288 If you build with Visual C++ 2015 or later then \fIext/XS\-APItest/t/locale.t\fR
289 may crash (after all its tests have passed). This is due to a regression in the
290 Universal CRT introduced in the Windows 10 April 2018 Update, and will be fixed
291 in the May 2019 Update, as explained here: <https://developercommunity.visualstudio.com/content/problem/519486/setlocalelc\-numeric\-iso\-latin\-16\-fails\-then\-succee.html>.
292 .PP
293 If you build with certain versions (e.g. 4.8.1) of gcc from mingw then
294 \&\fIext/POSIX/t/time.t\fR may fail test 17 due to a known bug in those gcc builds:
295 see <https://sourceforge.net/p/mingw/bugs/2152/>.
296 .PP
297 Some test failures may occur if you use a command shell other than the
298 native "cmd.exe", or if you are building from a path that contains
299 spaces. So don't do that.
300 .PP
301 If you are running the tests from a emacs shell window, you may see
302 failures in op/stat.t. Run "gmake test-notty" in that case.
303 .PP
304 Furthermore, you should make sure that during \f(CW\*(C`make test\*(C'\fR you do not
305 have any GNU tool packages in your path: some toolkits like Unixutils
306 include some tools (\f(CW\*(C`type\*(C'\fR for instance) which override the Windows
307 ones and makes tests fail. Remove them from your path while testing to
308 avoid these errors.
309 .PP
310 To see the output of specific failing tests run the harness from the t
311 directory:
312 .PP
313 .Vb 3
314 \& # assuming you\*(Aqre starting from the win32 directory
315 \& cd ..\ewin32
316 \& .\eperl harness <list of tests>
317 .Ve
318 .PP
319 Please report any other failures as described under "BUGS AND CAVEATS".
320 .SS "Installation of Perl on Windows"
321 .IX Subsection "Installation of Perl on Windows"
322 Type "gmake install" ("nmake install"). This will
323 put the newly built perl and the libraries under whatever \f(CW\*(C`INST_TOP\*(C'\fR
324 points to in the Makefile. It will also install the pod documentation
325 under \f(CW\*(C`$INST_TOP\e$INST_VER\elib\epod\*(C'\fR and HTML versions of the same
326 under \f(CW\*(C`$INST_TOP\e$INST_VER\elib\epod\ehtml\*(C'\fR.
327 .PP
328 To use the Perl you just installed you will need to add a new entry to
329 your PATH environment variable: \f(CW\*(C`$INST_TOP\ebin\*(C'\fR, e.g.
330 .PP
331 .Vb 1
332 \& set PATH=c:\eperl\ebin;%PATH%
333 .Ve
334 .PP
335 If you opted to uncomment \f(CW\*(C`INST_VER\*(C'\fR and \f(CW\*(C`INST_ARCH\*(C'\fR in the makefile
336 then the installation structure is a little more complicated and you will
337 need to add two new PATH components instead: \f(CW\*(C`$INST_TOP\e$INST_VER\ebin\*(C'\fR and
338 \&\f(CW\*(C`$INST_TOP\e$INST_VER\ebin\e$ARCHNAME\*(C'\fR, e.g.
339 .PP
340 .Vb 1
341 \& set PATH=c:\eperl\e5.6.0\ebin;c:\eperl\e5.6.0\ebin\eMSWin32\-x86;%PATH%
342 .Ve
343 .SS "Usage Hints for Perl on Windows"
344 .IX Subsection "Usage Hints for Perl on Windows"
345 .IP "Environment Variables" 4
346 .IX Item "Environment Variables"
347 The installation paths that you set during the build get compiled
348 into perl, so you don't have to do anything additional to start
349 using that perl (except add its location to your PATH variable).
350 .Sp
351 If you put extensions in unusual places, you can set PERL5LIB
352 to a list of paths separated by semicolons where you want perl
353 to look for libraries. Look for descriptions of other environment
354 variables you can set in perlrun.
355 .Sp
356 You can also control the shell that perl uses to run \fBsystem()\fR and
357 backtick commands via PERL5SHELL. See perlrun.
358 .Sp
359 Perl does not depend on the registry, but it can look up certain default
360 values if you choose to put them there unless disabled at build time with
361 USE_NO_REGISTRY. On Perl process start Perl checks if
362 \&\f(CW\*(C`HKEY_CURRENT_USER\eSoftware\ePerl\*(C'\fR and \f(CW\*(C`HKEY_LOCAL_MACHINE\eSoftware\ePerl\*(C'\fR
363 exist. If the keys exists, they will be checked for remainder of the Perl
364 process's run life for certain entries. Entries in
365 \&\f(CW\*(C`HKEY_CURRENT_USER\eSoftware\ePerl\*(C'\fR override entries in
366 \&\f(CW\*(C`HKEY_LOCAL_MACHINE\eSoftware\ePerl\*(C'\fR. One or more of the following entries
367 (of type REG_SZ or REG_EXPAND_SZ) may be set in the keys:
368 .Sp
369 .Vb 7
370 \& lib\-$] version\-specific standard library path to add to @INC
371 \& lib standard library path to add to @INC
372 \& sitelib\-$] version\-specific site library path to add to @INC
373 \& sitelib site library path to add to @INC
374 \& vendorlib\-$] version\-specific vendor library path to add to @INC
375 \& vendorlib vendor library path to add to @INC
376 \& PERL* fallback for all %ENV lookups that begin with "PERL"
377 .Ve
378 .Sp
379 Note the \f(CW$]\fR in the above is not literal. Substitute whatever version
380 of perl you want to honor that entry, e.g. \f(CW5.6.0\fR. Paths must be
381 separated with semicolons, as usual on Windows.
382 .IP "File Globbing" 4
383 .IX Item "File Globbing"
384 By default, perl handles file globbing using the File::Glob extension,
385 which provides portable globbing.
386 .Sp
387 If you want perl to use globbing that emulates the quirks of DOS
388 filename conventions, you might want to consider using File::DosGlob
389 to override the internal \fBglob()\fR implementation. See File::DosGlob for
390 details.
391 .IP "Using perl from the command line" 4
392 .IX Item "Using perl from the command line"
393 If you are accustomed to using perl from various command-line
394 shells found in UNIX environments, you will be less than pleased
395 with what Windows offers by way of a command shell.
396 .Sp
397 The crucial thing to understand about the Windows environment is that
398 the command line you type in is processed twice before Perl sees it.
399 First, your command shell (usually CMD.EXE) preprocesses the command
400 line, to handle redirection, environment variable expansion, and
401 location of the executable to run. Then, the perl executable splits
402 the remaining command line into individual arguments, using the
403 C runtime library upon which Perl was built.
404 .Sp
405 It is particularly important to note that neither the shell nor the C
406 runtime do any wildcard expansions of command-line arguments (so
407 wildcards need not be quoted). Also, the quoting behaviours of the
408 shell and the C runtime are rudimentary at best (and may, if you are
409 using a non-standard shell, be inconsistent). The only (useful) quote
410 character is the double quote ("). It can be used to protect spaces
411 and other special characters in arguments.
412 .Sp
413 The Windows documentation describes the shell parsing rules here:
414 <https://docs.microsoft.com/en\-us/windows\-server/administration/windows\-commands/cmd>
415 and the C runtime parsing rules here:
416 <https://msdn.microsoft.com/en\-us/library/17w5ykft%28v=VS.100%29.aspx>.
417 .Sp
418 Here are some further observations based on experiments: The C runtime
419 breaks arguments at spaces and passes them to programs in argc/argv.
420 Double quotes can be used to prevent arguments with spaces in them from
421 being split up. You can put a double quote in an argument by escaping
422 it with a backslash and enclosing the whole argument within double quotes.
423 The backslash and the pair of double quotes surrounding the argument will
424 be stripped by the C runtime.
425 .Sp
426 The file redirection characters "<", ">", and "|" can be quoted by
427 double quotes (although there are suggestions that this may not always
428 be true). Single quotes are not treated as quotes by the shell or
429 the C runtime, they don't get stripped by the shell (just to make
430 this type of quoting completely useless). The caret "^" has also
431 been observed to behave as a quoting character, but this appears
432 to be a shell feature, and the caret is not stripped from the command
433 line, so Perl still sees it (and the C runtime phase does not treat
434 the caret as a quote character).
435 .Sp
436 Here are some examples of usage of the "cmd" shell:
437 .Sp
438 This prints two doublequotes:
439 .Sp
440 .Vb 1
441 \& perl \-e "print \*(Aq\e"\e"\*(Aq "
442 .Ve
443 .Sp
444 This does the same:
445 .Sp
446 .Vb 1
447 \& perl \-e "print \e"\e\e\e"\e\e\e"\e" "
448 .Ve
449 .Sp
450 This prints "bar" and writes "foo" to the file "blurch":
451 .Sp
452 .Vb 1
453 \& perl \-e "print \*(Aqfoo\*(Aq; print STDERR \*(Aqbar\*(Aq" > blurch
454 .Ve
455 .Sp
456 This prints "foo" ("bar" disappears into nowhereland):
457 .Sp
458 .Vb 1
459 \& perl \-e "print \*(Aqfoo\*(Aq; print STDERR \*(Aqbar\*(Aq" 2> nul
460 .Ve
461 .Sp
462 This prints "bar" and writes "foo" into the file "blurch":
463 .Sp
464 .Vb 1
465 \& perl \-e "print \*(Aqfoo\*(Aq; print STDERR \*(Aqbar\*(Aq" 1> blurch
466 .Ve
467 .Sp
468 This pipes "foo" to the "less" pager and prints "bar" on the console:
469 .Sp
470 .Vb 1
471 \& perl \-e "print \*(Aqfoo\*(Aq; print STDERR \*(Aqbar\*(Aq" | less
472 .Ve
473 .Sp
474 This pipes "foo\enbar\en" to the less pager:
475 .Sp
476 .Vb 1
477 \& perl \-le "print \*(Aqfoo\*(Aq; print STDERR \*(Aqbar\*(Aq" 2>&1 | less
478 .Ve
479 .Sp
480 This pipes "foo" to the pager and writes "bar" in the file "blurch":
481 .Sp
482 .Vb 1
483 \& perl \-e "print \*(Aqfoo\*(Aq; print STDERR \*(Aqbar\*(Aq" 2> blurch | less
484 .Ve
485 .Sp
486 Discovering the usefulness of the "command.com" shell on Windows 9x
487 is left as an exercise to the reader :)
488 .Sp
489 One particularly pernicious problem with the 4NT command shell for
490 Windows is that it (nearly) always treats a % character as indicating
491 that environment variable expansion is needed. Under this shell, it is
492 therefore important to always double any % characters which you want
493 Perl to see (for example, for hash variables), even when they are
494 quoted.
495 .IP "Building Extensions" 4
496 .IX Item "Building Extensions"
497 The Comprehensive Perl Archive Network (CPAN) offers a wealth
498 of extensions, some of which require a C compiler to build.
499 Look in <https://www.cpan.org/> for more information on CPAN.
500 .Sp
501 Note that not all of the extensions available from CPAN may work
502 in the Windows environment; you should check the information at
503 <https://www.cpantesters.org/> before investing too much effort into
504 porting modules that don't readily build.
505 .Sp
506 Most extensions (whether they require a C compiler or not) can
507 be built, tested and installed with the standard mantra:
508 .Sp
509 .Vb 4
510 \& perl Makefile.PL
511 \& $MAKE
512 \& $MAKE test
513 \& $MAKE install
514 .Ve
515 .Sp
516 where \f(CW$MAKE\fR is whatever 'make' program you have configured perl to
517 use. Use "perl \-V:make" to find out what this is. Some extensions
518 may not provide a testsuite (so "$MAKE test" may not do anything or
519 fail), but most serious ones do.
520 .Sp
521 It is important that you use a supported 'make' program, and
522 ensure Config.pm knows about it.
523 .Sp
524 Note that MakeMaker actually emits makefiles with different syntax
525 depending on what 'make' it thinks you are using. Therefore, it is
526 important that one of the following values appears in Config.pm:
527 .Sp
528 .Vb 3
529 \& make=\*(Aqnmake\*(Aq # MakeMaker emits nmake syntax
530 \& any other value # MakeMaker emits generic make syntax
531 \& (e.g GNU make, or Perl make)
532 .Ve
533 .Sp
534 If the value doesn't match the 'make' program you want to use,
535 edit Config.pm to fix it.
536 .Sp
537 If a module implements XSUBs, you will need one of the supported
538 C compilers. You must make sure you have set up the environment for
539 the compiler for command-line compilation before running \f(CW\*(C`perl Makefile.PL\*(C'\fR
540 or any invocation of make.
541 .Sp
542 If a module does not build for some reason, look carefully for
543 why it failed, and report problems to the module author. If
544 it looks like the extension building support is at fault, report
545 that with full details of how the build failed using the GitHub
546 issue tracker at <https://github.com/Perl/perl5/issues>.
547 .IP "Command-line Wildcard Expansion" 4
548 .IX Item "Command-line Wildcard Expansion"
549 The default command shells on DOS descendant operating systems (such
550 as they are) usually do not expand wildcard arguments supplied to
551 programs. They consider it the application's job to handle that.
552 This is commonly achieved by linking the application (in our case,
553 perl) with startup code that the C runtime libraries usually provide.
554 However, doing that results in incompatible perl versions (since the
555 behavior of the argv expansion code differs depending on the
556 compiler, and it is even buggy on some compilers). Besides, it may
557 be a source of frustration if you use such a perl binary with an
558 alternate shell that *does* expand wildcards.
559 .Sp
560 Instead, the following solution works rather well. The nice things
561 about it are 1) you can start using it right away; 2) it is more
562 powerful, because it will do the right thing with a pattern like
563 */*/*.c; 3) you can decide whether you do/don't want to use it; and
564 4) you can extend the method to add any customizations (or even
565 entirely different kinds of wildcard expansion).
566 .Sp
567 .Vb 10
568 \& C:\e> copy con c:\eperl\elib\eWild.pm
569 \& # Wild.pm \- emulate shell @ARGV expansion on shells that don\*(Aqt
570 \& use File::DosGlob;
571 \& @ARGV = map {
572 \& my @g = File::DosGlob::glob($_) if /[*?]/;
573 \& @g ? @g : $_;
574 \& } @ARGV;
575 \& 1;
576 \& ^Z
577 \& C:\e> set PERL5OPT=\-MWild
578 \& C:\e> perl \-le "for (@ARGV) { print }" */*/perl*.c
579 \& p4view/perl/perl.c
580 \& p4view/perl/perlio.c
581 \& p4view/perl/perly.c
582 \& perl5.005/win32/perlglob.c
583 \& perl5.005/win32/perllib.c
584 \& perl5.005/win32/perlglob.c
585 \& perl5.005/win32/perllib.c
586 \& perl5.005/win32/perlglob.c
587 \& perl5.005/win32/perllib.c
588 .Ve
589 .Sp
590 Note there are two distinct steps there: 1) You'll have to create
591 Wild.pm and put it in your perl lib directory. 2) You'll need to
592 set the PERL5OPT environment variable. If you want argv expansion
593 to be the default, just set PERL5OPT in your default startup
594 environment.
595 .Sp
596 If you are using the Visual C compiler, you can get the C runtime's
597 command line wildcard expansion built into perl binary. The resulting
598 binary will always expand unquoted command lines, which may not be
599 what you want if you use a shell that does that for you. The expansion
600 done is also somewhat less powerful than the approach suggested above.
601 .IP "Notes on 64\-bit Windows" 4
602 .IX Item "Notes on 64-bit Windows"
603 Windows .NET Server supports the LLP64 data model on the Intel Itanium
604 architecture.
605 .Sp
606 The LLP64 data model is different from the LP64 data model that is the
607 norm on 64\-bit Unix platforms. In the former, \f(CW\*(C`int\*(C'\fR and \f(CW\*(C`long\*(C'\fR are
608 both 32\-bit data types, while pointers are 64 bits wide. In addition,
609 there is a separate 64\-bit wide integral type, \f(CW\*(C`_\|_int64\*(C'\fR. In contrast,
610 the LP64 data model that is pervasive on Unix platforms provides \f(CW\*(C`int\*(C'\fR
611 as the 32\-bit type, while both the \f(CW\*(C`long\*(C'\fR type and pointers are of
612 64\-bit precision. Note that both models provide for 64\-bits of
613 addressability.
614 .Sp
615 64\-bit Windows running on Itanium is capable of running 32\-bit x86
616 binaries transparently. This means that you could use a 32\-bit build
617 of Perl on a 64\-bit system. Given this, why would one want to build
618 a 64\-bit build of Perl? Here are some reasons why you would bother:
619 .RS 4
620 .IP \(bu 4
621 A 64\-bit native application will run much more efficiently on
622 Itanium hardware.
623 .IP \(bu 4
624 There is no 2GB limit on process size.
625 .IP \(bu 4
626 Perl automatically provides large file support when built under
627 64\-bit Windows.
628 .IP \(bu 4
629 Embedding Perl inside a 64\-bit application.
630 .RE
631 .RS 4
632 .RE
633 .SS "Running Perl Scripts"
634 .IX Subsection "Running Perl Scripts"
635 Perl scripts on UNIX use the "#!" (a.k.a "shebang") line to
636 indicate to the OS that it should execute the file using perl.
637 Windows has no comparable means to indicate arbitrary files are
638 executables.
639 .PP
640 Instead, all available methods to execute plain text files on
641 Windows rely on the file "extension". There are three methods
642 to use this to execute perl scripts:
643 .IP 1. 8
644 There is a facility called "file extension associations". This can be
645 manipulated via the two commands "assoc" and "ftype" that come
646 standard with Windows. Type "ftype /?" for a complete example of how
647 to set this up for perl scripts (Say what? You thought Windows
648 wasn't perl-ready? :).
649 .IP 2. 8
650 Since file associations don't work everywhere, and there are
651 reportedly bugs with file associations where it does work, the
652 old method of wrapping the perl script to make it look like a
653 regular batch file to the OS, may be used. The install process
654 makes available the "pl2bat.bat" script which can be used to wrap
655 perl scripts into batch files. For example:
656 .Sp
657 .Vb 1
658 \& pl2bat foo.pl
659 .Ve
660 .Sp
661 will create the file "FOO.BAT". Note "pl2bat" strips any
662 \&.pl suffix and adds a .bat suffix to the generated file.
663 .Sp
664 If you use the 4DOS/NT or similar command shell, note that
665 "pl2bat" uses the "%*" variable in the generated batch file to
666 refer to all the command line arguments, so you may need to make
667 sure that construct works in batch files. As of this writing,
668 4DOS/NT users will need a "ParameterChar = *" statement in their
669 4NT.INI file or will need to execute "setdos /p*" in the 4DOS/NT
670 startup file to enable this to work.
671 .IP 3. 8
672 Using "pl2bat" has a few problems: the file name gets changed,
673 so scripts that rely on \f(CW$0\fR to find what they must do may not
674 run properly; running "pl2bat" replicates the contents of the
675 original script, and so this process can be maintenance intensive
676 if the originals get updated often. A different approach that
677 avoids both problems is possible.
678 .Sp
679 A script called "runperl.bat" is available that can be copied
680 to any filename (along with the .bat suffix). For example,
681 if you call it "foo.bat", it will run the file "foo" when it is
682 executed. Since you can run batch files on Windows platforms simply
683 by typing the name (without the extension), this effectively
684 runs the file "foo", when you type either "foo" or "foo.bat".
685 With this method, "foo.bat" can even be in a different location
686 than the file "foo", as long as "foo" is available somewhere on
687 the PATH. If your scripts are on a filesystem that allows symbolic
688 links, you can even avoid copying "runperl.bat".
689 .Sp
690 Here's a diversion: copy "runperl.bat" to "runperl", and type
691 "runperl". Explain the observed behavior, or lack thereof. :)
692 Hint: .gnidnats llits er'uoy fi ,"lrepnur" eteled :tniH
693 .SS "Miscellaneous Things"
694 .IX Subsection "Miscellaneous Things"
695 A full set of HTML documentation is installed, so you should be
696 able to use it if you have a web browser installed on your
697 system.
698 .PP
699 \&\f(CW\*(C`perldoc\*(C'\fR is also a useful tool for browsing information contained
700 in the documentation, especially in conjunction with a pager
701 like \f(CW\*(C`less\*(C'\fR (recent versions of which have Windows support). You may
702 have to set the PAGER environment variable to use a specific pager.
703 "perldoc \-f foo" will print information about the perl operator
704 "foo".
705 .PP
706 One common mistake when using this port with a GUI library like \f(CW\*(C`Tk\*(C'\fR
707 is assuming that Perl's normal behavior of opening a command-line
708 window will go away. This isn't the case. If you want to start a copy
709 of \f(CW\*(C`perl\*(C'\fR without opening a command-line window, use the \f(CW\*(C`wperl\*(C'\fR
710 executable built during the installation process. Usage is exactly
711 the same as normal \f(CW\*(C`perl\*(C'\fR on Windows, except that options like \f(CW\*(C`\-h\*(C'\fR
712 don't work (since they need a command-line window to print to).
713 .PP
714 If you find bugs in perl, you can report them to
715 <https://github.com/Perl/perl5/issues>.
716 .SH "BUGS AND CAVEATS"
717 .IX Header "BUGS AND CAVEATS"
718 Norton AntiVirus interferes with the build process, particularly if
719 set to "AutoProtect, All Files, when Opened". Unlike large applications
720 the perl build process opens and modifies a lot of files. Having the
721 AntiVirus scan each and every one slows build the process significantly.
722 Worse, with PERLIO=stdio the build process fails with peculiar messages
723 as the virus checker interacts badly with miniperl.exe writing configure
724 files (it seems to either catch file part written and treat it as suspicious,
725 or virus checker may have it "locked" in a way which inhibits miniperl
726 updating it). The build does complete with
727 .PP
728 .Vb 1
729 \& set PERLIO=perlio
730 .Ve
731 .PP
732 but that may be just luck. Other AntiVirus software may have similar issues.
733 .PP
734 A git GUI shell extension for Windows such as TortoiseGit will cause the build
735 and later \f(CW\*(C`make test\*(C'\fR to run much slower since every file is checked for its
736 git status as soon as it is created and/or modified. TortoiseGit doesn't cause
737 any test failures or build problems unlike the antivirus software described
738 above, but it does cause similar slowness. It is suggested to use Task Manager
739 to look for background processes which use high CPU amounts during the building
740 process.
741 .PP
742 Some of the built-in functions do not act exactly as documented in
743 perlfunc, and a few are not implemented at all. To avoid
744 surprises, particularly if you have had prior exposure to Perl
745 in other operating environments or if you intend to write code
746 that will be portable to other environments, see perlport
747 for a reasonably definitive list of these differences.
748 .PP
749 Not all extensions available from CPAN may build or work properly
750 in the Windows environment. See "Building Extensions".
751 .PP
752 Most \f(CWsocket()\fR related calls are supported, but they may not
753 behave as on Unix platforms. See perlport for the full list.
754 .PP
755 Signal handling may not behave as on Unix platforms (where it
756 doesn't exactly "behave", either :). For instance, calling \f(CWdie()\fR
757 or \f(CWexit()\fR from signal handlers will cause an exception, since most
758 implementations of \f(CWsignal()\fR on Windows are severely crippled.
759 Thus, signals may work only for simple things like setting a flag
760 variable in the handler. Using signals under this port should
761 currently be considered unsupported.
762 .PP
763 Please report detailed descriptions of any problems and solutions that
764 you may find at <<https://github.com/Perl/perl5/issues>>,
765 along with the output produced by \f(CW\*(C`perl \-V\*(C'\fR.
766 .SH ACKNOWLEDGEMENTS
767 .IX Header "ACKNOWLEDGEMENTS"
768 The use of a camel with the topic of Perl is a trademark
769 of O'Reilly and Associates, Inc. Used with permission.
770 .SH AUTHORS
771 .IX Header "AUTHORS"
772 .IP "Gary Ng <[email protected]>" 4
773 .IX Item "Gary Ng <[email protected]>"
774 .PD 0
775 .IP "Gurusamy Sarathy <[email protected]>" 4
776 .IX Item "Gurusamy Sarathy <[email protected]>"
777 .IP "Nick Ing-Simmons <nick@ing\-simmons.net>" 4
778 .IX Item "Nick Ing-Simmons <[email protected]>"
779 .IP "Jan Dubois <[email protected]>" 4
780 .IX Item "Jan Dubois <[email protected]>"
781 .IP "Steve Hay <[email protected]>" 4
782 .IX Item "Steve Hay <[email protected]>"
783 .PD
784 .PP
785 This document is maintained by Jan Dubois.
786 .SH "SEE ALSO"
787 .IX Header "SEE ALSO"
788 perl
789 .SH HISTORY
790 .IX Header "HISTORY"
791 This port was originally contributed by Gary Ng around 5.003_24,
792 and borrowed from the Hip Communications port that was available
793 at the time. Various people have made numerous and sundry hacks
794 since then.
795 .PP
796 GCC/mingw32 support was added in 5.005 (Nick Ing-Simmons).
797 .PP
798 Support for PERL_OBJECT was added in 5.005 (ActiveState Tool Corp).
799 .PP
800 Support for \fBfork()\fR emulation was added in 5.6 (ActiveState Tool Corp).
801 .PP
802 Win9x support was added in 5.6 (Benjamin Stuhl).
803 .PP
804 Support for 64\-bit Windows added in 5.8 (ActiveState Corp).
805 .PP
806 Last updated: 06 October 2021