Automating Windows with Perl
by Rick Smith (September 2, 2001)
B O O K I
N F O R M A T I O N
Windows with Perl
Miller Freeman Inc.
1601 W. 23rd Street
Lawrence, KS 66046
This book is one of the growing number of Perl books that concentrate almost exclusively on the Windows usage of Perl. This book demonstrates how to perform some Windows-specific tasks like controlling Microsoft Office components and automated backups, along with CGI development in a Windows environment.
Automating Windows with Perl gets started right away by describing what it is and what it isn't. Briefly, this book is for power users or administrators that are currently able to write "useful programs" in Perl. It does not teach Perl, but demonstrates how to effectively use Perl to help automate Windows tasks.
Scott McMahan, the author, also describes some of the great features of Perl to further automate Windows. Some of these are:
"It doesn't limit your thinking" -- Perl offers several different ways to accomplish the same task
Integrated Math and report capability, unlike DOS Batch files
Easy access to operating system -- no need for external "helper" apps used in Batch files
Logical language syntax.
Someone learning Perl might debate this last point, because Perl has a large, powerful syntax that takes time and can be cryptic, but Perl's syntax is logical. Scott also compares the Perl language to several other current languages such as LISP, C, C++ and Java.
Before delving into COM techniques, Scott provides the source code needed to simulate a Cron job in Windows and a function to send SMTP mail via TCP sockets. While the Perl Cron "clone" can be quite useful, the SMTP module is extremely simplified, since no provisions were made for any error checking or result code verification.
This book delves into how to automate Microsoft Word and Excel and rebuild Developer Studio projects. The author then details each step in creating a C++ DLL in Developer Studio, which can be called by Perl. Since the Windows development world is multilingual, he also also shows how to call this DLL from Visual Basic, LotusScript, Delphi and C++.
Of particular interest, in the CGI chapter of this book, is a very frank and realistic discussion of the pros and cons of using Windows as a web server. Since the author has "used both UNIX and Windows side-by-side for several years now", his debate is thought provoking. You really need to read his sobering reasons why Windows NT with IIS is a "compelling testing and development platform", yet is "not compelling as a production platform". Don't forget, he wrote this discussion before Windows-based web servers became hacked so often in 2001.
This book closes by:
Listing the source code for two useful Windows utilities written in Perl
Describing several good editors
Discussing why fork() doesn't exist in Windows
Demonstrating how to develop Perl Programs in Developer Studio
Automating Windows with Perl is well written and easy to read. If you know some Perl and use Windows, this book provides a great Windows perspective to help advance your Perl knowledge by using Perl for automation tasks and CGI development.
© 2001 Rick Smith All rights reserved.