Debian Codegraph @

upstream/fedora-44/man1/perlwin32.1

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