Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


September 1998

Inside the New Perl Resource Kit


RSS
Subscribe to Windows IT Pro | See More Resource Kit Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Download the Code Here

Perl for Win32 takes a quantum leap forward

Quantum leaps of functionality in well-established technologies, especially programming languages, aren't common. However, Perl Resource Kit--Win32 Edition is a quantum leap for Perl on the Win32 platform. The Perl resource kit is a product of O'Reilly & Associates, but ActiveState Tool contributed the new Win32 Perl software on the kit's CD-ROM. The resource kit contains advances in functionality that will significantly affect the Windows NT and Perl communities. These advancements include a new release of Perl, new tools and utilities, and extensive documentation.

New Release of Perl
The most significant advancement in the Perl resource kit is the release of Perl 5.005. This version consolidates the two most popular Win32 builds of Perl: CORE and Perl for Win32. Before version 5.005, users chose between these Win32 Perl implementations because the two builds offered different functions in some areas and implemented the same functions differently in others. Their disparity resulted in code that ran under one build but not the other. Version 5.005 effectively merges the two builds into one comprehensive package that eliminates past incompatibilities.

Fortunately, there are only minor code incompatibilities between version 5.005 and previous versions of CORE and Perl for Win32. The area primarily affected deals with Object Linking and Embedding (OLE) support. People who used ActiveState's OLE implementation will need to change the way they instantiate and access objects. This incompatibility and the other minor incompatibilities are well documented in the resource kit's release notes.

New Tools and Utilities
Perl 5.005 isn't the only software in the Perl resource kit. The kit also includes ActiveState's Perl Debugger, Perl for Internet Server API (ISAPI), Perl for Website, PerlScript, and Perl2Exe. Three new commercial software packages that I like are Perl Package Manager (PPM), PerlCOM, and PerlCtrl.

PPM. With PPM, users easily install, manage, and remove add-on Perl packages. Packages are third-party libraries, such as modules and extensions, that extend Perl's capabilities. For example, the Win32::AdminMisc module I discussed in last month's column ("How to Manage Your Enterprise's Passwords the Easy Way," August 1998) is a package.

If you are a long-time Perl user, you probably know about the hassles involved with installing, managing, and removing packages. For example, if you install a new version of Perl, you must verify that the code in your existing modules doesn't break. If problems arise, you must find a module update that is compatible with the new version of Perl. If an update module isn't available, you remove the Perl upgrade and wait until the module developer releases an updated version. Another problem users encounter when installing packages is that some packages require numerous installation steps, including a compilation phase that is beyond the scope of many Perl users.

With PPM, configuring third-party Perl packages is a snap. PPM comes in two versions: a console-based version, which retains the name PPM, and a browser-based version, Visual Package Manager (VPM). PPM and VPM have three primary functions: Install, which installs a new package from a specified repository URL; Remove, which removes a currently installed package; and Verify, which verifies whether an installed package is up-to-date and optionally updates the package if it's not.

Installing packages with VPM takes only a few mouse clicks. You select the URL repository, select which packages you want to download, and click Install, as Screen 1, page 196, shows.

Only time will tell how useful VPM and PPM will be. However, my prediction is that these two management tools will reduce the complexity and frustration with using third-party packages.

PerlCOM. With PerlCOM, you create instances of Perl and Perl modules from within any programming environment that supports Microsoft's component object model (COM), including Windows Scripting Host (WSH), Visual Basic (VB), Visual Basic for Applications (VBA), and Delphi. A PerlCOM.Script object makes PerlCOM's magic possible.

PerlCtrl. With PerlCtrl, you build COM automation servers in Perl. A COM automation server is a self-contained reusable .dll file that exposes methods and properties that any COM controller can instantiate and use.

With the Perl resource kit, using third-party packages is a snap.
The difference between PerlCOM and PerlCtrl is that PerlCOM is a COM automation server that exposes the PerlCOM.Script object and associated methods. PerlCtrl lets you build your own COM servers complete with their unique GUIDs and ProgIDs. ProgIDs are the friendly names you use to refer to an object class. For example, PerlCOM.Script and WScript.Shell are ProgIDs. Let's look at a PerlCOM example. I'll demonstrate PerlCtrl in a future column.

PerlCOM in Action
Suppose you want to use WSH with Visual Basic Script (VBScript) to execute an external command and capture the command's standard output. Although you can use WSH's Run method via the Shell object to execute the command, no simple method exists to capture the command's output. Instead, you must redirect the command's output to a file, open the file, parse it, close it, and finally delete the file.

Executing a command and capturing its output are much easier with the Perl resource kit because you can execute the Perl code via the PerlCOM object. The example BackTicks.vbs script in Listing 1 shows you how to create and use a PerlCOM object. Let's examine how this script works.

Like other objects used from within a WSH script, you first need to create an object of type "PerlCOM.Script" to execute Perl code. At callout A in Listing 1, the PerlCOM object is objPerlCOM. You use the EvalScript method to execute standard Perl code. With EvalScript, you can create Perl variables that become properties of the PerlCOM object, or define Perl subroutines that become methods of the object.

   Previous  [1]  2  Next 


Top Viewed ArticlesView all articles
2009 Windows IT Pro Editors' Best and Community Choice Awards

Picking a favorite product from an impressive crowd of competitive offerings is never an easy task, and such was the case with our Editors' Best and Community Choice awards this year. ...

Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

WinInfo Short Takes: Week of November 23, 2009

An often irreverent look at some of the week's other news, including some post-PDC some soul searching, a Google Chrome OS announcement and a Microsoft response, Windows 7 off to a supposedly strong start, the Jonas Brothers and Xbox 360, and so much more ...


Related Articles Perl COM Objects

Task Automation Whitepapers From Development to Production: Streamlining SharePoint Deployment with DocAve Deployment Manager

Related Events Deep Dive into Windows Server 2008 R2 presented by John Savill

Check out our list of Free Email Newsletters!

Task Automation eBooks Spam Fighting and Email Security for the 21st Century

A Guide to Windows Certification and Public Keys

Keeping Your Business Safe from Attack: Patch Management

Related Task Automation Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement