Visual Test, or similar, to build mouse-click, keystroke macros. Very cool, but not even portable to the NT machine sitting next to it if the screen resolution is different.
Automation
Perl lets you write things as simple as "macros" that play back a sequence
of command lines - a 'glorified batch file', as one of my students said - to
connecting to applications via OLE, and doing stuff from within those Windows
applications.
System administration
With a variety of Perl modules, you can get direct access to the Windows administration API. This is great for repetitive tasks, and for preventing Carpal Tunnel Syndrome.
There are three places to get Perl for NT. There are all mostly the same thing, but some come with some gizmos that other do not.
ActiveState
ActiveState is Dick Hardt's company, which provides Perl binaries for NT, wrapped in a nice install program. It comes with a nice variety of Win32::* extension modules. ActiveState is funded in part
by Mocrosoft, but this should not be construed to mean that Mocrosoft has in any way "bought Perl".
I recommend, especially if you use NT and Unix systems, that you install Perl in the c:\usr directory, rather than the default c:\perl directory. The advantage to this is that Perl will then be at /usr/bin/perl on NT, as well as on Unix, and you don't have to change any of the #! lines in your programs. This is particularly an issue if you are running Perl CGI programs on Apache server, since not much else on NT understands the #! notation.
Build it yourself
If you have VC++, and more patience than I do, you can get the Perl source from CPAN and build it yourself.
That other guy
I can't remember his name, and I'm not going to spend any time looking for it, but he's out there somewhere. A disgruntled former ActiveState employee that is convinced that Dick Hardt is the AntiCamel, and provides his own NT build of Perl. He seems, to me at least, to be more than a little unbalanced.
Due to the absence of things like "make" on NT machines, it is sometimes not particularly easy to install the modules that you want. There are three ways to install modules on ActivePerl.
PPM
The PPM - Perl Package Manager - is part of the ActiveState install. It works a lot like the CPAN module, assisting you to download and install Perl modules. At the command line, type PPM, and you'll get an interactive prompt that looks like PPM> Type help at the prompt to get a list of all the options available to you. There's HTML documentation in the html subdirectory of your installation directory.
Install manually
For some modules - so called "pure perl" modules that don't have a C component - you can install the module by just copying the .pm files into their correct directory. For example, if you want to install Mail::Sendmail, just unpack the Mail-Sendmail file from CPAN, create a c:\usr\lib\Mail directory, and copy Sendmail.pm into that directory.
make; make test; make install
If you have VC++, and you know what you are doing, you can build modules yourself. I have never gotten this to work, because I am not familiar with VC++.
Well, because it's Perl, you can do all the stuff that you would ordinarily do with Perl. Because it's on Windows, you can also hook into various Win32 APIs to do Windows-specific things. There are a variety of Win32::* extension modules to do everything from adding users to managing your NT domain, to editing the registry.
The following code clears your makes a backup copy of the contents of your event log, clears the event log, and gzips the backup file.
#!/usr/bin/perl
use Win32::EventLog;
use Time::CTime;
use strict;
my ($Event, @timearray, $filename,
$day, $month);
for ('System', 'Security', 'Application') {
$Event = new Win32::EventLog ("$_", "");
@timearray=localtime(time);
$month = sprintf ('%.2d', $timearray[4] +1);
$day = sprintf ('%.2d', $timearray[3]);
$filename = 'c:/EventLogs/' . ($timearray[5]+1900) . '_' .
$month . '_' . $day . '_' . $_ . '.events';
$Event->Clear($filename);
`gzip -9 $filename`;
} # End for
Notice that I'm making a system call to gzip, which is not usually a part of NT. You can get several different gzips for NT, or you can use one of the Compress::* modules, and convert that line to Perl code instead.
To perform this task the way that NT expects you to, you have to click about 8 buttons and menu items, but with it written like this, you can put it in your crontab to run on a schedule. Automation is my friend, since I have 50+ NT servers at the moment.
Get Dave Roth's book!
No, not that Dave Roth! Dave's book covers all of the standard Win32::* extensions that come with ActivePerl. It's an invaluable resource.
For some examples of what you can do with Perl on Win32, see the Scripts area of CPAN. One of the things on there is a little tool that I wrote, drw_monitor, which watches the Dr Watson log on your NT machine, and emails you, and/or sends an alpha page, when there is an application crash.
There's no sendmail that comes with NT. This makes the task of sending email a little sticky for folks that are used to just forking off a sendmail process. However, the right way to do this on NT turns out to be the right way to do it on Unix also, so it's worth learning. Rather than using sendmail, you should use Mail::Sendmail, or one of the other related CPAN modules. There's a good article on this in the Summer 1999 issue of the Perl Journal.
use Mail::Sendmail;
my %mail = (To => 'rbowen@rcbowen.com',
From=> 'fubar@rcbowen.com',
Subject=>'Mail::Sendmail',
Message=>'Mail::Sendmail rocks!',
);
sendmail(%mail) or die $Mail::Sendmail::error;
There are also a number of commercial sendmail relacements for NT, such as Windmail fro GeoCel.
For some of the other cool tools that I use on NT, see http://www.rcbowen.com/imho/NT/
[
Lexington.pm
]