ActiveState Home Page       Win32 FAQ


NAME

perlwin32faq1 - Availability and Installation



DESCRIPTION

Getting, installing, and using Perl.



What is Perl?

Perl is a scripting language widely used for system administration and programming on the World Wide Web. It originated in the UNIX community and has a strong UNIX slant, but usage on the Win32 platforms is growing rapidly. With the coming of the Perl Resource Kit for Win32, Perl on Win32 is just as powerful as it is on UNIX systems.

perl (small 'p') is the program used to interpret the Perl language.



Where can I get tons of information about Perl?

Extensive online documentation is included with Perl itself. You can read the documentation with the perldoc command, as in perldoc document_name. You should start with the perl document and the perlfaq document. For information on other ways of accessing the Perl documentation (including HTML versions of this documentation), see Where can I get documentation on Perl for Win32?.

To get more information about Perl, check out these URLs:

There are several good books about Perl. The premier book on Perl for Win32 is Learning Perl On Win32 Systems By Schwartz, Olson, and Christiansen (O'Reilly & Associates, 1997). This is the Gecko book, and has a picture of a gecko (little chubby lizard with big toes and a smile) on the front cover.

For general perl, two books to consider are Programming Perl, 2nd Edition, by Larry Wall, Tom Christiansen and Randal L. Schwartz (O'Reilly & Associates, 1996) and Learning Perl, by Randal L. Schwartz (O'Reilly & Associates, 1993). These are referred to by Perl enthusiasts as the Camel book and the Llama book, respectively.

If you are new to Perl and there are any terms mentioned in this FAQ that you don't get, try one of the above resources. See the perlbook document that comes with Perl for more information.



Where is the Perl for Win32 interpreter available?

The Perl for Win32 package is available by anonymous FTP from ActiveState and from CPAN, the Comprehensive Perl Archive Network.

To download from ActiveState, look in this directory:


  http://www.ActiveState.com/pw32/


What do I get with ActiveState's Perl for Win32?

ActiveState's Perl for Win32 is a complete, self-installing distribution of Perl based on the standard Perl sources. It is distributed online at the ActiveState site and is bundled with the Perl Resource Kit for Win32. See http://www.ActiveState.com and http://perl.oreilly.com for more information.

``Perl for Win32'' generally refers to the ActiveState release of Perl.

Perl for Win32 was developed by ActiveState Tool Corporation (originally Hip Communications) for Microsoft Corporation. This effort was undertaken for inclusion in Microsoft's Windows NT Resource Kit.

Since then, ActiveState and various Perl porters have worked to keep Perl for Win32 current with the standard release of Perl. The oneperl effort, a joint effort between O'Reilly, ActiveState, and various volunteers, has joined the Win32 and standard Perl source code into one common source tree.

The Perl Resource Kit for Win32 from O'Reilly includes perl, PerlIS, the Perl Debugger, and several Win32-specific modules and tools developed by ActiveState.



How do I install the Perl for Win32 package?

Simply double-click the archive you downloaded, and you will be guided through the installation process by the installation wizard. You can select the parts of the Perl package you want installed, and the location you want to install them to.



How can I customize my installation of Perl for Win32?

NOTE: The following information applies only if you have a versioned perl installation. Newer versions of ActivePerl use a simple (non-versioned) installation structure by default, which is described here. See the perlwin32 documentation page for more information on how to get a versioned installation.

Perl uses the @INC array as a search path for use'd and require'd files. (run perl -V to see what's in @INC) This can be manipulated at run-time with use lib 'directory_to_add' or by modifying the Registry or environment. By default, the following directories are added to @INC:


    <myperldir>/site/<version>/lib/<architecturename>
    <myperldir>/site/<version>/lib
    <myperldir>/<version>/lib/<architecturename>
    <myperldir>/<version>/lib

Where <myperldir> is your Perl home directory, such as C:\Perl. And <architecturename> is something like MSWin32-x86 or MSWin32-Alpha.

There are a few registry entries you can use to customize your setup. Under the following keys: [HKEY_LOCAL_MACHINE/Software/Perl/] and [HKEY_CURRENT_USER/Software/Perl/], you can add the following String values:


    LIB
    LIB-<perlversion>

such as:


    LIB
    LIB-5.0050

This adds the directory, or directories, you specify to the default lib paths (for Perl 5.005, this is C:\Perl\5.00500\lib\MSWin32-x86 and C:\Perl\5.00500\lib). The LIB-<perlversion> allows you to customize the path for a given version of Perl, if you have multiple versions of Perl installed. SITELIB SITELIB-<perlversion>

such as:


    SITELIB
    SITELIB-5.0050

This adds the directory, or directories, you specify to the default sitelib paths (for Perl 5.005, this is C:\Perl\site\5.00500\lib\MSWin32-x86, C:\Perl\site\5.00500\lib, and C:\Perl\site\lib). The SITELIB-<perlversion> allows you to customize the site path for a given version of Perl, if you have multiple versions of Perl installed.

[HKEY_CURRENT_USER/Software/Perl] is searched before [HKEY_LOCAL_MACHINE/Software/Perl], so you can customize Perl on a per-user basis.

In addition, if you set the environment variable Perl5lib, it will be added to @INC as well. Perl5lib will be looked up in the environment first, and then in the registry as outlined above.



How do I uninstall Perl for Win32?

Go to Add/Remove Programs in the Control Panel, choose Perl for Win32 from the list box, and click Remove.



What is ActiveX Scripting?

ActiveX Scripting is a Microsoft technology that consists of script engines and script hosts. A script engine, such as PerlScript, VBScript, or JScript, is a programming language that can be embedded in a scripting host, such as Windows Scripting Host, Microsoft Exchange, and Active Server Pages (ASP).



Is there an ActiveX Scripting version of Perl available?

Yes. This is called PerlScript. It is part of the Perl for Win32 package, and can be optionally installed during installation.

PerlScript can be used within any ActiveX Scripting Host such as Microsoft Internet Explorer 4.0, Microsoft Exchange, and the Windows Scripting Host.



What other scripting languages are available for Win32 platforms?

Although it's possible to program in batch language or with QBASIC (a 16-bit BASIC interpreter that comes with Windows 95 and Windows NT), serious programmers will probably prefer one of the following other options:

Python

A very full-featured language, widely-used. OOP, networking, CGI, database, GUI programming. See http://www.python.org/

Object REXX

An update of REXX for the OOP decade. See http://www2.hursley.ibm.com/orexx/

Tcl/Tk

The Tool Command Language. More information is available at http://www.tclconsortium.org

Awk and UNIX shell languages are available in several UNIX-to-NT packages (see Where can I find Win32 ports of UNIX tools?). 4NT and 4DOS scripting are popular among the shell scripting languages. (4DOS also solves some of the command shell problems under Windows 95/98, and, with a little work, even makes thing better under NT.)



When I double-click the perl.exe icon in Explorer, I get an empty DOS window with a blinking cursor.

Perl for Win32 is a Win32 command-line program. It expects to be run from the command line, not from Explorer.

If you want to run a Perl script, write the script out using a text editor like Notepad. A good starter program is:


    print "Hello, World!\n";

Save the program to a file (such as C:\temp\hello.pl). Now, start a command prompt window (sometimes erroneously called a DOS window), and type the following line at the command prompt:


    C:\> perl c:\temp\hello.pl

This should print out the words Hello, World! on the screen. You may have to do some fiddling with the PATH environment variable, or specify the full path name to perl.exe, in order for this to work.

perl.exe has a lot of nifty command-line arguments that can make your work easier. See perlrun for details.

To answer the original question about what's happening when you start perl from an Explorer window rather than a command-line window: starting from Explorer is roughly the same as starting perl without any command line arguments. When perl is started without a script file specified on the command line, it expects to receive a Perl program as standard input, i.e., from the keyboard.

The blinking cursor means perl is waiting for your input. You can actually type in a Perl program from the keyboard, and then tell perl to execute it by typing the Ctrl-Z, which is the end-of-file marker on Windows systems.



How can I get Perl to run a Perl script at the 4DOS command line by typing the name of the script without the extension or "perl", just like a regular exe file?

See also How do I associate Perl scripts with perl?.

You can add a line like


    SET .PL=C:\PERL\BIN\PERL.EXE

to your AUTOEXEC.BAT file under Win95/98. You can then type <scriptname> with no extension to run your script, even if you are not in the same directory as the script and the script path is on your path.

Note, however, that this only works with 4DOS, not COMMAND.COM, CMD32.EXE, or CMD.EXE. With those shells you still need to type


    perl scriptname.pl <arg> <arg> <arg>


Can I build perl from the source code?

The Perl source code includes complete instructions on building Perl. You can obtain the latest Perl source from:


    http://www.perl.com/CPAN/src/latest.tar.gz

Once you extract the source, read the README and README.win32 files for instructions on compiling Perl.

On Windows, you have a choice of building a version of Perl using a Win32 compiler or building it with a development environment that offers emulation of many UNIX features, such as fork(). Using a native Win32 compiler will also allow you to more easily hook into Win32 APIs, such as ODBC, ASP, ISAPI, and others. Also, the native Win32 builds of Perl for Win32 are more widely used and are thus better tested.

If you need a development tool that integrates wonderfully with the rest of the Win32 environment, go with a native Win32 build of Perl. If you need comprehensive emulation of UNIX under Win32, you should build it under an environment that provides UNIX emulation.

At one time, many modules and extensions did not work under Win32 because of UNIXisms in the code and incompatibilities in Perl for Win32. This has changed significantly (on both sides of the equation), and a large majority of modules now work with a native version of Perl for Win32.

You can use the following C compilers to build a native Win32 build of Perl:

Microsoft's Visual C++ (commercial product)

The Microsoft compiler, which includes compilation tools, API and tool documentation, and an integrated development environment.


    http://www.microsoft.com/visualc/
Borland C++ Builder (commercial product)

Borland C++ provides an integrated development environment, compilation tools, and documentation for building Win32 applications.


    http://www.inprise.com/bcppbuilder/
Mingw32 Libraries with GCC or EGCS Compilers (free software)

GCC and EGCS are both high quality freeware compilers that have been ported to the Win32 platform. Together with the freely available Mingw32 libraries, they can be used to build Perl and extensions. They do not provide an integrated development environment, and all of the tools must be run from the command line. The Mingw32 library reuses some of the code developed for Cygwin32 (see below).

EGCS/Mingw32 binaries can be obtained from:


    ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/mingw32/

GCC/Mingw32 binaries are available at:


    http://agnes.dida.physik.uni-essen.de/~janjaap/mingw32/
Cygwin32 (free software)

You can approximate a UNIX development and execution environment on Win32 with the Cygwin32 toolchain. This is a port of numerous GNU tools, and includes an emulation API that provides access to many UNIX features not found on Win32:


    http://www.cygnus.com/misc/gnu-win32


AUTHOR AND COPYRIGHT

This FAQ was originally assembled and maintained by Evangelo Prodromou. evangelo@endcontsw.com. It has been revised and updated by Brian Jepson of O'Reilly and Associates, and David Grove and David Dmytryshyn of ActiveState.

This FAQ is in the public domain. If you use it, however, please ensure that you give credit to the original authors.

ActiveState Home Page       Win32 FAQ