ActivePerl Documentation
Table of Contents

(Usage Statistics)
(about this ver)

* Getting Started
    * Welcome To ActivePerl
    * Release Notes
    * Readme
    * ActivePerl Change Log
* Install Notes
    * Linux
    * Solaris
    * Windows
* ActivePerl Components
    * Overview
    * PPM
    * Windows Specifics
       * OLE Browser
       * PerlScript
       * Perl for ISAPI
       * PerlEZ
* ActivePerl FAQ
    * Introduction
    * Availability & Install
    * Using PPM
    * Docs & Support
    * Windows Specifics
       * Perl for ISAPI
       * Windows 9X/NT/2000
       * Quirks
       * Web Server Config
       * Web programming
       * Programming
       * Modules & Samples
       * Embedding & Extending
       * Using OLE with Perl
* Windows Scripting
    * Active Server Pages
    * Windows Script Host
    * Windows Script Components

Core Perl Documentation

* perl
* perlfaq
* perltoc
* perlbook

* perlsyn
* perldata
* perlop
* perlreftut
* perldsc
* perllol

* perllexwarn
* perldebug

* perlrun
* perlfunc
* perlopentut
* perlvar
* perlsub
* perlmod
* perlpod

* perlstyle
* perlmodlib
* perlmodinstall
* perltrap
* perlport
* perlsec

* perlref
* perlre
* perlform
* perllocale
* perlunicode

* perlboot
* perltoot
* perltootc
* perlobj
* perlbot
* perltie

* perlipc
* perlnumber
* perlfork
* perlthrtut

* perldiag
* perlfaq1
* perlfaq2
* perlfaq3
* perlfaq4
* perlfaq5
* perlfaq6
* perlfaq7
* perlfaq8
* perlfaq9

* perlcompile

* perlembed
* perlxstut
* perlxs
* perlguts
* perlcall
* perlfilter
* perldbmfilter
* perlapi
* perlintern
* perlapio
* perltodo
* perlhack

* perlhist
* perldelta
* perl5005delta
* perl5004delta

* perlamiga
* perlcygwin
* perldos
* perlhpux
* perlmachten
* perlos2
* perlos390
* perlvms
* perlwin32


* attributes
* attrs
* autouse
* base
* blib
* bytes
* charnames
* constant
* diagnostics
* fields
* filetest
* integer
* less
* lib
* locale
* lwpcook
* open
* ops
* overload
* perllocal
* re
* sigtrap
* strict
* subs
* utf8
* vars
* warnings


* ActivePerl
    * DocTools
        * TOC
            * RDF
* AnyDBM_File
* Archive
    * Tar
* AutoLoader
* AutoSplit
* B
    * Asmdata
    * Assembler
    * Bblock
    * Bytecode
    * C
    * CC
    * Debug
    * Deparse
    * Disassembler
    * Lint
    * Showlex
    * Stackobj
    * Terse
    * Xref
* Benchmark
* Bundle
    * LWP
* ByteLoader
* Carp
    * Heavy
    * Apache
    * Carp
    * Cookie
    * Fast
    * Pretty
    * Push
    * Switch
* Class
    * Struct
* Compress
    * Zlib
* Config
    * FirstTime
    * Nox
* Cwd
* Data
    * Dumper
* DB
* Devel
    * DProf
    * Peek
    * SelfStubber
* Digest
    * HMAC
    * HMAC_MD5
    * HMAC_SHA1
    * MD2
    * MD5
    * SHA1
* DirHandle
* Dumpvalue
* DynaLoader
* English
* Env
* Errno
* Exporter
    * Heavy
* ExtUtils
    * Command
    * Embed
    * Install
    * Installed
    * Liblist
    * MakeMaker
    * Manifest
    * Miniperl
    * Mkbootstrap
    * Mksymlists
    * MM_Cygwin
    * MM_OS2
    * MM_Unix
    * MM_VMS
    * MM_Win32
    * Packlist
    * testlib
* Fatal
* Fcntl
* File
    * Basename
    * CheckTree
    * Compare
    * Copy
    * CounterFile
    * DosGlob
    * Find
    * Glob
    * Listing
    * Path
    * Spec
        * Functions
        * Mac
        * OS2
        * Unix
        * VMS
        * Win32
    * stat
* FileCache
* FileHandle
* FindBin
* Font
    * AFM
* Getopt
    * Long
    * Std
    * AsSubs
    * Element
    * Entities
    * Filter
    * Form
    * FormatPS
    * Formatter
    * FormatText
    * HeadParser
    * LinkExtor
    * Parse
    * Parser
    * TokeParser
    * TreeBuilder
    * Cookies
    * Daemon
    * Date
    * Headers
        * Util
    * Message
    * Negotiate
    * Request
        * Common
    * Response
    * Status
* I18N
    * Collate
* IO
    * Dir
    * File
    * Handle
    * Pipe
    * Poll
    * Seekable
    * Select
    * Socket
        * INET
        * UNIX
    * Msg
    * Open2
    * Open3
    * Semaphore
    * SysV
    * Debug
    * MediaTypes
    * MemberMixin
    * Protocol
    * RobotUA
    * Simple
    * UserAgent
* Math
    * BigFloat
    * BigInt
    * Complex
    * Trig
* MD5
    * Base64
    * QuotedPrint
* NDBM_File
* Net
    * Cmd
    * Config
    * Domain
    * DummyInetd
    * FTP
    * hostent
    * libnetFAQ
    * netent
    * Netrc
    * NNTP
    * PH
    * Ping
    * POP3
    * protoent
    * servent
    * SMTP
    * SNPP
    * Time
* O
* ODBM_File
* Opcode
* Pod
    * Checker
    * Find
    * Html
    * InputObjects
    * Man
    * Parser
    * ParseUtils
    * Plainer
    * Select
    * Text
        * Color
        * Termcap
    * Usage
    * SOAPClient
    * SOAPServer
* Safe
* SDBM_File
* Search
    * Dict
* SelectSaver
* SelfLoader
* Shell
    * Defs
    * Envelope
    * EnvelopeMaker
    * GenericHashSerializer
    * GenericInputStream
    * GenericScalarSerializer
    * Lite
    * OutputStream
    * Packager
    * Parser
    * Transport
        * HTTP
            * Apache
            * CGI
            * Client
            * Server
        * LOCAL
        * MAILTO
        * POP3
        * TCP
    * TypeMapper
* Socket
* Symbol
* Sys
    * Hostname
    * Syslog
* Term
    * ANSIColor
    * Cap
    * Complete
    * ReadLine
* Test
    * Harness
* Text
    * Abbrev
    * ParseWords
    * Soundex
    * Tabs
    * Wrap
* Thread
    * Queue
    * Semaphore
    * Signal
    * Specific
* Tie
    * Array
    * Handle
    * Hash
    * RefHash
    * Scalar
    * SubstrHash
* Time
    * gmtime
    * Local
    * localtime
    * tm
    * Lite
    * data
    * Escape
    * file
    * Heuristic
    * ldap
    * URL
    * WithBase
* User
    * grent
    * pwent
* Win32
    * AuthenticateUser
    * ChangeNotify
    * Clipboard
    * Console
    * Event
    * EventLog
    * File
    * FileSecurity
    * Internet
    * IPC
    * Mutex
    * NetAdmin
    * NetResource
    * ODBC
    * OLE
        * Const
        * Enum
        * NEWS
        * NLS
        * TPJ
        * Variant
    * PerfLib
    * Pipe
    * Process
    * Registry
    * Semaphore
    * Service
    * Sound
    * TieRegistry
* Win32API
    * File
    * Net
    * Registry
    * RobotRules
        * AnyDBM_File
    * Element
    * Parser
        * Expat
    * PPD
    * PPMConfig
    * ValidatingElement
* XSLoader

 ActivePerl FAQ


perlwin32faq4 - Windows NT and Windows 95


Useful information about Windows NT and Windows 95 for Perl developers

Where can I get Windows NT information?

A good starting place is the printed documentation that came with Windows NT and on the Windows NT CD in the support\books directory. Windows Help files are also available.

You can get some in-depth information on Windows NT from the Windows NT Resource Kit, available at bookstores and from Microsoft. Microsoft TechNet is also a valuable resource.

World Wide Web support for Windows NT Server is at:

Support for Windows NT Workstation is at:

Where can I get Windows 95/98 information?

Printed documentation comes with Windows 95/98, as well as some documentation on the CD-ROM. Help files are available from the Start menu.

The Windows 95 Resource Kit contains in-depth information on Windows 95. It's available at bookstores and software stores.

World Wide Web support for Windows 95/98 is at:

What's the equivalent of the shebang ("#!") syntax for Win32?

Unfortunately, Win32 platforms don't provide the shebang syntax, or anything like it. You can try one of the two following methods to run a script from the command line. If all else fails, you can always just call the perl interpreter directly, as in perl

Although Win32 systems themselves don't use the shebang, the Apache webserver does. If you are using the Apache webserver on your Win32 system you should put the shebang line at the top of your CGI scripts.

Your shebang line should look something like:


For Windows NT 4.0, the coolest method is to use associated file types (see How do I associate Perl scripts with perl?). If you've associated Perl scripts with the .pl extension, you can just type the name of your file at the command line and Windows NT will launch perl.exe for you. If you change the PATHEXT environment variable to include .pl files, like this:


you can just type the file name without an extension, and Windows NT will find the first .pl file in your path with that name. You may want to set PATHEXT in the System control panel rather than on the command line. Otherwise, you'll have to re-enter it each time the command prompt window closes.

Given this setup, you can have a Perl script called that looks like this:

    while ( <> ) {

and you can invoke it on the command line like this:

    cat myfile.txt

However, you can't invoke it with I/O redirection, like this:

    cat < myfile.txt
    cat myfile.txt | more

although it looks like you should be able to (this is a limitation of Windows NT). Your script can be in your path or you can provide a path to the file.

Note that the file association method does not work for Windows 95, nor does it work with Windows NT if you have command extensions disabled. You can, however, still start the Perl script from an Explorer window if the extension is associated with perl.

Another option is to use the pl2bat utility distributed with ActivePerl to convert your Perl script into a batch file. What this does is tag some Win32 batch language to the front of your script so that the system calls the perl interpreter on the file. It's quite a clever piece of batch coding, actually.

If you call the pl2bat utility on your Perl script, like this:

    C:\> pl2bat

it will produce a batch file, helloworld.bat. You can then invoke the script just like this:

    C:\> helloworld
    Hello, World!

You can pass command line parameters, as well. Your script can be in your PATH, or in another directory, and the pl2bat code will usually find it and execute it correctly. The big advantage of this over file associations is that I/O redirection will work correctly.

pl2bat has a number of useful command line options to affect how the wrapping is done, what command line switches to pass to perl, etc. Running perldoc pl2bat at the command line will show a full description of these options.

The pl2exe utility is similar to pl2bat, but it puts an executable header on your perl script, producing an EXE file that cannot be directly edited. Redirection also works correctly under scripts that have been run through pl2exe.

What's the equivalent of chmod for Win32?

There is no direct equivalent of the chmod tool on Win32 systems. For file attributes, you can use the ATTRIB command line tool (type HELP ATTRIB at the command line for details). For more complex permissions, see How do I set permissions on a file?.

For information on the chmod() function, see How does the chmod function work on Win32 platforms?.

How do I send email from ActivePerl?

You may come across scripts that send email with an external mail program, as in:

        open(MAIL, '| /usr/lib/sendmail') or "die";
        print MAIL <<EOF;
        Hello, World!

These sort of scripts generally cause people to ask, ``is there a sendmail equivalent on Windows?'' If you need to send email from a Perl script, there is no need to use an external program like sendmail. The libnet bundle includes Net::SMTP, a module that can be used to send mail. Here is an example:

        use Net::SMTP;

        $smtp = Net::SMTP->new(''); # connect to an SMTP server
        $smtp->mail( '' );     # use the sender's address here
        $smtp->to('');        # recipient's address
        $smtp->data();                      # Start the mail

        # Send the header.

        # Send the body.
        $smtp->datasend("Hello, World!\n");
        $smtp->dataend();                   # Finish sending the mail
        $smtp->quit;                        # Close the SMTP connection

Another alternative is Mail::Sender, which can be used like so:

        use Mail::Sender;
        $sender = new Mail::Sender {smtp => '', from => ''};
        $sender->MailFile({to => '', subject => 'Here is the file', 
                       msg => "I'm sending you the list you wanted.", 
                           file => 'filename.txt'});

Or Mail::Sendmail, which can be used like this:

        use Mail::Sendmail;

        %mail = ( To      => '',
                  From    => '',
                  Message => "This is a minimalistic message"

        if (sendmail %mail) { print "Mail sent OK.\n" }
        else { print "Error sending mail: $Mail::Sendmail::error \n" }
A Perl script for sending mail without using an external program is also available on Robin Chatterjee's Perl for Win32 page (see Are there information sources available on ActivePerl on the World Wide Web?).

If you really need a sendmail equivalent for Windows, several such equivalents exist:


Blat is a public domain program for sending email from the Windows NT command-line. Although it is reputed to work under Windows 95, the Blat authors have not tested it under Windows 95. The Blat home page is located at


Microsoft has a port of sendmail available on their FTP site at

A commercial sendmail product is available from MetaInfo, Inc. An evaluation version is available at


Another commercial mail product is wrmail, part of the slmail product from Seattle Labs. A free version is available at

How do I schedule jobs on Win32 platforms?

The UNIX cron utility doesn't exist on Win32 platforms.

For Windows NT, a scheduling tool called AT is available. Unlike the UNIX cron utility, AT doesn't store its schedule in a flat file, but is configured using command-line arguments. Note the AT command seems to be very picky about syntax. Here is one example:

        at 23:37 /interactive /every:M,T,W,Th,F,S,Su cmd /c "c:\perl\bin\perl.exe c:\"

If you don't like the command-line version of AT, there's a GUI version, WinAT, which is available with the Windows NT Resource Kit. The "Schedule" service must be running when your job is supposed to happen.

Note that you may have problems when running AT or WinAT if the scheduled program or script requires any special rights or permissions other than those held by "System" (ie, if it is working across computers or NT domains). This is because NT does not properly allow you to run preinstalled NT services, such as the "Schedule" service as a user with network priveleges. It may look like you can set the scheduler to login as a user with network priveledges, but the service just does not recognize that user's right's and permissions and the System userid has only local permissions.

An all-Perl cron-like solution exists at which uses a familiar Unix-like crontab file. This script can be ran as an NT Service (see How do I set up a Perl script as an NT Service?). When you create your own NT service, NT lets you set the useid/password pair, and these services do recognize that userid's rights and permissions. Hence, the scheduled program or script will have the necessary rights.

There are a few commercial cron-like schedulers. NTcrond, is available from ifdef software: and AutoTask2000 is available from These programs should recognize the rights and priveleges of the userid you set their service to run under to enable the scheduled program or script to have the necessary rights.

For Windows 95, there's a System Agent available with the Microsoft Plus! Pack. Also, there are several shareware scheduling utilities, notably LaunchPad and Metz Scheduler. These can be found on a good shareware search engine, such as There is also an optional "Task Scheduler" component with IE4.01 and Windows 98.

Because scheduled jobs on Windows NT run as a service (see What is a Windows NT service?), you need to take special steps to make sure that files and environment variables are available to your script.

In some instances, Perl's internal sleep function might be an appropriate means of scheduling. For example:

        $seconds = 180;
        sub action;
        while(1) {


Where can I find Win32 ports of UNIX tools?

You might want to take a look at the help file for Windows NT and Windows 95 commands to see if there's a rough equivalent distributed with your Win32 platform. If not, try one of these URLs:

There are also several UNIX-like tools available in the Windows NT Resource Kit. Also, there are several UNIX-to-Win32 commercial packages available, including the MKS Toolkit from Mortice Kerns Systems, Inc.: and Interix from Softway Systems: (the product formerly known as OpenNT).

You can also check into the Perl Power Tools, being developed under the UNIX Reconstruction Project. Here you can find UNIX tools that are being reimplemented into all Perl. You can see the latest at

What is a Windows NT service?

On Windows NT, a service is a special kind of executable program that runs in the background. Services are used for programs that are constantly working, such as network protocols or database servers. Most WWW servers on Windows NT are implemented as services.

A service is different from other programs in several ways:

  • Services aren't run interactively, although the NET START and NET STOP commands can be used to start or stop a server. The Services control panel is used to start, stop, or pause a service.

  • Services don't act with the authority of the logged-in user. That means that services can't see user environment variables or read files that are readable only by the logged-in user. You can set the account that a service uses in the Services control panel.

  • Services run even when no one is logged in to the machine.

The most important thing to remember is that you have to take special steps to make resources available to services. In general, you need to make files available to the Everyone group, and you have to have environment variables (like PATH) be system environment variables.

How do I run a Perl script as a Windows NT Service?

You can run your Perl scripts as Windows NT Services via a program called srvany.exe, which comes with the Windows NT Resource Kit. Once srvany.exe is installed, read the srvany.wri file which should be with it. This document will explain how to set up registry entries for your new service.

After you are set up, to run your script as a service do:

  x:>srvany perl

How do I set permissions on a file?

Win32 platforms don't have the same mechanisms for setting permissions on files as UNIX does. For files on FAT partitions (which means all files in Windows 95), you don't have to set permissions explicitly on a file. All files are available to all users.

For files on an NTFS partition on Windows NT, you can set the security permissions on a file using the Explorer and the properties sheet of the file. Right-click the file in Explorer, and choose Properties from the drop-down menu. Select the Security tab, and click Permissions to set the Permissions on the file. Click Help for more information.

A command-line program, CACLS, will also change the permissions on a file. For more details, type HELP CACLS on the command line.

Windows 95/98 machines that are administered using Novell can have accounts and permissions similiar to NT. However, these permissions must be set up by the Novell administrator.

How do I associate Perl scripts with perl?

On Windows systems, association is the process of specifying which programs should be used for which kind of files. Files are grouped into file types, such as JPEG files or Perl scripts. The file type of a file is identified by its file name extension (all the letters after the last ``.'' in the file name).

So, for example, we can say that there's a type of file called a text file, which has the file extension .txt, and which is handled by the Notepad program.

Usually, ActivePerl programmers create a file type like Perl Script and associate the extension .pl with that type. We specify that the perl interpreter binary, perl.exe, is responsible for that file type. Several Web servers require that you associate your scripts with perl.exe before the script can be run.

On Windows 95 and Windows NT 4.0, you can create a new file type and associate the perl interpreter with it as follows:

  1. Open the My Computer icon on the Desktop. The My Computer window should appear.

  2. From the View menu in the My Computer window, choose Options. The Options dialog box appears.

  3. In the Options dialog box, select the File Types tab.

  4. Click the New Type button. The Add New File Type dialog box appears.

  5. In the ``Description of type'' box, type ``Perl Script''.

  6. In the ``Associated extension'' box, type ``.pl''.

  7. Leave the Content Type (MIME) box blank.

  8. Click the New button beneath the Actions list. The New Action dialog box will appear.

  9. In the Action box, type ``Open'' (it's important to use this name for the action!).

  10. In the ``Application used to perform action'' box, type [full path to perl]\perl.exe %1 %*, where [full path to perl] is the full path to perl.exe on your machine. If perl is in your path, you can put just perl.exe, but for esoteric reasons it's better to put the full path. Also, if the path to your interpreter includes spaces (like C:\Program Files\perl5) put in the DOS path instead (C:\progra~1\perl5).

  11. Click OK to close the New Action dialog box.

  12. Click OK to close the Add New File Type dialog box.

  13. Click OK to close the Options dialog box.

You can test your association by double-clicking on a perl script in the Explorer window. If perl.exe starts and executes the script, things are OK.

On Windows NT 4.0, you can avoid all the hassle of the above and just type the following from the command line:

    ASSOC .pl=PerlScript
    FTYPE PerlScript=[full path to perl]\perl.exe %1 %*

For more information on these commands, type HELP FTYPE at the command prompt.

Note that for this to work you have to have command extensions enabled. (These are enabled by default; you'd know if you'd turned them off.)

Why doesn't 'perl -e' work?

It does - it's just that some command shells (for example COMMAND.COM, CMD.EXE and 4DOS) don't accept single quotes wrapped around command arguments.

The safest way to do perl one-liners is to wrap the parameters within "" (double-quotes) the use q() and qq() inside the parameters. q() and qq() with put whatever is inside them between single-quotes or double-quotes, respectively.
For example:

perl -e "use LWP::Simple; while(@c = head <>) { $c = join qq(\n\t), @c; print qq(Header info:\n\t$c\n); }"

(this was all one line)
Run this from the command line and type in the URL to your favorite website, like

The perlwin32 and perlrun POD pages have more information on using the command line.

What editors are available for Windows?

Windows comes with two editors that are great for editing Perl, NotePad and WordPad. But, if you need more features for ease of editing, here is a list of free and commercial editors:

  • BBEdit -
    • A Macintosh editor that supports multiple languages including Perl. By adding Brad Hanson's BBEdit Plug-Ins you can run your Perl scripts right in BBEdit


  • CodeWright -
    • With Codewright, you choose the compiler, the assembler, the version control system--any tools you like--and Codewright works with you. Includes Perl language support.


  • ED for Windows -
    • ED leads the way in intelligent language sensitive editing. Supporting both DOS and Windows, ED is as easy to use as it is to spell. Up and running straight out of the box for the new user but highly configurable, ED fits the way YOU want to work. Includes support for Perl syntax highlighting.


  • GNU Emacs for Windows -
    • "Emacs is the extensible, customizable, self-documenting real-time display editor."


  • HomeSite -
    • HomeSite 4.0 is the award-winning HTML editing tool that lets you build great Web sites in less time, while maintaining Pure HTML. Good editor for ASP, and PerlScript.


  • MultiEdit -
    • MultiEdit is an multiple language editor. Perl language support includes - smart indenting, template editing, construct matching, code completion, context highlighting, brace/parenthesis alignment and line-numbering. Other MulitEdit features include multiple file search/replace, HTML and ASP support, web site management, integration with several IDEs and debuggers, and the ability to compare and sychronize files while editing.


  • NoteTab -
    • Seamless support for Perl and Gawk scripts (only commercial versions).


  • Perl Builder -
    • Perl Builder is a complete, integrated development environment (IDE) for Perl. Whether you are an experienced Perl developer or a non-programmer who needs to create Perl CGI scripts, Perl Builder's visual tools are guaranteed to dramatically improve your productivity! Perl Builder is a 32-bit application and requires Windows 95 or NT.


  • Perl Scripting Tool -
    • PST was intended as a replacement for Windows' Notepad, which until now has been the editor of choice for Win32 PERL Programmers. While Notepad is usually sufficient there has long been the need for something with 'just a little more'. This simple editor is Notepad with a few extra options for PERL script authoring, including a subroutine library, code wizard, run, debug, syntax check, floating toolbox and more. An extremely simple and straight-forward PERL GUI.


  • Programmer's File Editor (PFE) -
    • PFE is a large-capacity, multi-file editor that runs on Windows 98, Windows 95, Windows NT 4.0 and Windows 2000 on Intel-compatible processors, and on Windows 3.1x. Although it's primarily oriented towards program developers and contains features like the ability to run compilers and development applications, it also makes a very good general purpose editor for any function at all.


  • TextPad -
    • TextPad is a fully featured text editor for Windows. 16 and 32 bit editions available.


  • UltraEdit -
    • UltraEdit is a disk based editor with a 16-Bit version for Windows 3.x and a 32-Bit version for Windows NT and Windows 95 (not Win32s). It includes bazillions of features including a Perl wordfile for Perl syntax highlighting.


  • VIM -
    • The "Vi IMproved" editor -- Now with Perl support. VIM provides Perl syntax highlighting, and a Perl interface. The Perl interface provides the ability to run a Perl command or run a Perl command for each line in a range. For more information on Perl support, see the Perl and VIM help page.


  • VisualSlickEdit -
    • Visual SlickEdit combines the richest set of powerful editing features with more configurability than any software product in any category. Visual SlickEdit is multi-platform, highly extensible, and fast -- Includes language color-coding extention for Perl.


  • WinEdit -



This FAQ was originally assembled and maintained by Evangelo Prodromou. It has been revised and updated by Brian Jepson of O'Reilly and Associates, and David Grove, David Dmytryshyn of ActiveState, Kevin Meltzer, Eric Smith and David Sparks of ActiveState.

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

 ActivePerl FAQ