Subscribe to Windows IT Pro
September 01, 1998 12:00 AM

Inside the New Perl Resource Kit

Windows IT Pro
InstantDoc ID #3775
Rating: (0)

After creating objPerlCOM, the script creates a new scalar variable (sProperty) and initializes it with the string to the right of the assignment operator (=). You must enclose the Perl code that you want to pass to EvalScript in double quotes. The script then uses the standard VBScript MsgBox function and dot notation to access and display the property's value.

The code at B uses EvalScript to define the Perl subroutine, vbsBackTicks. This subroutine becomes the method that executes the external command and returns the command's standard output as a string. You must enclose the Perl code that you pass to EvalScript in double quotes. When the code spans several lines, you must use VBScript's line continuation character (_) and string concatenation character (&) to ensure that the script passes the entire subroutine to EvalScript as one string.

Like sProperty, the vbsBackTicks subroutine is basic Perl code. The subroutine begins by initializing the two local scalars, $command and $delimiter. (When the script later invokes vbsBackTicks, the script passes these values to the subroutine.) The next line of the subroutine executes the user-defined command using Perl's backtick operator (`) and assigns the command's output to the @output array. The subroutine's last line uses Perl's join operator and the user-defined delimiter to translate the array into a string and return the string to the calling object.

The next line in the script calls the vbsBackTicks method and passes the desired command ("net use") and delimiter ("@") to the vbsBackTicks method. The variable sOutput stores the value vbsBackTicks returns. The script uses VBScript's MsgBox function to display the output. The last line in the script uses VBScript's Nothing keyword to destroy the objPerlCOM object before the script ends.

After you run the BackTicks.vbs script, you will see the message boxes in Screen 2 and Screen 3. But PerlCOM's magic doesn't end here. You can use PerlCOM to create instances of Perl modules. With PerlCOM, you can extend Perl modules to any COM programming environment. For example, WSH doesn't provide a mechanism to read from or write to NT's event logs. You can use PerlCOM to create an instance of the Win32::EventLog module, making its functions available to WSH.

Extensive Documentation
The Perl resource kit features four volumes of documentation, totaling more than 1500 pages. Whether you're a novice or expert Perl programmer, you'll find the information in the four volumes of documentation useful.

The first volume is the Perl Utilities Guide, which covers the Perl Resource Kit's installation and setup, Perl language basics, and Perl programming for Web servers (including information specific to all major Web server platforms). This volume also contains the documentation for all the software included in the kit. The second module is Programming with Perl Modules, which teaches you how to leverage the hundreds of reusable Perl modules available from the Comprehensive Perl Archive Network (CPAN) at http://www.perl.com/CPAN. Programming with Perl Modules also teaches you how to create modules. The third and fourth modules constitute the Perl Module Reference. This two-volume set includes a comprehensive module index from which you can easily locate detailed module descriptions and usage instructions for hundreds of Perl modules.

A Significant Event
If you wrote BASIC programs in the late 1980s, you'll probably agree that what Microsoft has done to evolve the BASIC language is remarkable. You can say the same for what O'Reilly, ActiveState, and the Perl developer community have done for Perl. With a common code base in Perl 5.005, new utilities, new tools, and extensive documentation, Perl clearly becomes the most comprehensive scripting environment available for the Win32 platform.

You can purchase Perl Resource Kit--Win32 Edition from many retail bookstores. You can also purchase it online from O'Reilly & Associates (http://www.ora.com) and various online bookstores.

Related Content:

ARTICLE TOOLS

Comments
  • Anonymous User
    8 years ago
    Nov 10, 2004

    tyytrytrytr

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.