Uh-oh, it looks like your Internet Explorer is out of date.

For a better shopping experience, please upgrade now.

Learning Perl for WIN32

Learning Perl for WIN32

by Randal L. Schwartz, Erik Olson, Tom Christiansen

In this smooth, carefully paced course, leading Perl trainers and a Windows NT practitioner teach you to program in the language that promises to emerge as the scripting language of choice on NT. With a foreword by Larry Wall, the creator of Perl, this book is the "official" guide for both formal (classroom) and informal learning. Based on the "llama book,"


In this smooth, carefully paced course, leading Perl trainers and a Windows NT practitioner teach you to program in the language that promises to emerge as the scripting language of choice on NT. With a foreword by Larry Wall, the creator of Perl, this book is the "official" guide for both formal (classroom) and informal learning. Based on the "llama book," Learning Perl on Win32 Systems features tips for PC users and new NT-specific examples.

Perl for Win32 is a language for easily manipulating text, files, user and group profiles, performance and event logs, and registry entries, and a distribution is available on the Windows NT Resource Kit. Peer-to-peer technical support is now available on the perl.win32.users mailing list.

The contents include:

  • An introduction to "the Perl way" for Windows users
  • A quick tutorial stroll through Perl in one lesson
  • Systematic, topic-by-topic coverage of Perl's broad capabilities
  • Innumerable, brief code examples
  • Programming exercises for each topic, with fully worked-out answers
  • Access to NT system functions through Perl
  • Database access with Perl
  • CGI programming with Perl

Erik Olson is director of advanced technologies for Axiom Technologies, LC, where he specializes in providing Win32 development solutions. Randal L. Schwartz and Tom Christiansen have also written Programming Perl, co-authored with Larry Wall and published by O'Reilly & Associates.

Editorial Reviews

Doug Nickerson
Perl is an interpreted language that features powerful (and cool-looking) expressions with generally more than one way to manipulate them. With Perl, you can put arrays on both sides of the equals sign, write terse regular expressions using built-in operators, and structure`data with built-in hashes (or associative lists). Perl is Basic meets C meets APL, with objects and an Algol block structure thrown in. Surely serious use of Perl may be hazardous to your health.

Unlike its sister book Programming Perl, Learning Perl on Win32 Systems, by Randal L. Schwartz, Erik Olson, and Tom Christiansen, presents little danger that you will be overwhelmed by Perl's embarrassment of riches.

Learning Perl on Win32 Systems covers the basics of Perl in O'Reilly's trademark well-organized approach, but how much of Win32 is covered? Until about Chapter 10, I was concerned that Win32 might have been added as an afterthought. (O'Reilly's Learning Perl, the ancestor of this book, also included Randal Schwartz as an author.)

Rather than a complete reference to using Perl with Win32, this is Perl with a Win32 slant. Navigating directories, removing files, and getting system status; all are covered with commentary about what you must do to get these to work in Win32.

And because of Perl's UNIX heritage, frequent reference is made to how UNIX and Windows are different. In Perl, calling native Win32 functions, and many other functionalities not supported in the immediate language, is accomplished via extensions. In this book, examples of using some Win32 functions are in the main text, but comprehensive detail about using Win32 extensions is placed in an appendix.

This approach is fine. Win32 need not play much of a role in learning language basics, and the goal is to learn Perl -- not conquer all of its vagaries.

The tutorial in Chapter One is well thought out and the book includes ample exercises (with exercise solutions in an appendix). Covering as it does the basics of the language and providing an orientation for those programming under Windows, Perl beginners will find this book an excellent introduction to Perl.

Based on the second edition of Learning Perl, modified to be applicable to Perl programming on Windows NT systems. Provides a "gentle" (from the preface) introduction (rather than a comprehensive guide), touching on most common operations and language idioms found in Perl programs. Each chapter ends with exercises. Annotation c. by Book News, Inc., Portland, Or.

Product Details

O'Reilly Media, Incorporated
Publication date:
Perl Series
Edition description:
1 ED
Product dimensions:
7.00(w) x 9.19(h) x 0.74(d)

Read an Excerpt

Chapter 1: Introduction

In this chapter:

  • History of Perl
  • Purpose of Perl
  • Availability
  • Support
  • Basic Concepts
  • A Stroll Through Perl
  • Exercises

History of Perl

Perl is a language designed for people who need to get things done. Written by the amazing Larry Wall as a kind of glue language to tie together all of the loose ends of everyday computing life, Perl is a tool for leveraging the skills and tools that you already have. Perl has become an indispensable boon to Windows NT webmasters, power users, administrators, and programmers who have discovered how much easier it is to get their work done when Perl is doing some of it for them.

Do you know a little about C? Then you probably already know a lot about Perl. In fact, if you have used any programming or scripting language before, you might be surprised at how familiar Perl looks. Perl is not only an easy language to use, but also makes great use of your existing tools and solutions.

Perl is an easy language, but it's also a rich language, offering lots of functionality right out of the box. You'll be surprised at how much you can do with just a little bit of Perl code. Often, rewriting a small scrap of Perl wizardry requires hundreds of lines of C. Some languages that let you do a lot with a little don't let you do a whole lot. Perl not only lets you do a lot, it lets you do so with minimal effort. And if you run into something that you can't do in Perl, you'll find most likely that Perl will cooperate quite nicely with whatever you do have to do it in.

For many addicts, Perl is more than a language, it's an entire culture. For many folks, Perl was an indispensable part of their UNIX toolkits that they took with them to new environments. As a result, Perl grew, and became even more general and more powerful. What was once just an exceptional text-processing language that bound UNIX programs together has become a widespread language that seems to bind much of the Internet together. Perl is now used to create web pages, read Usenet news, do system administration and systems programming, write network clients and servers, and much more.

The three chief virtues of a Perl programmer (indeed, of any programmer) are sometimes said to be laziness, impatience, and hubris. Although these may seem like undesirable qualities at first blush (just ask your SO), there's more to this than there appears to be.

Laziness is the quality that makes you take great efforts to reduce the overall amount of work that you have to do. Lazy programmers are apt to develop reusable and general solutions that can be used in more than one place, and are more apt to document what they do, so that they don't have to ever waste time or torture their brains figuring it out again.

Impatient programmers get angry whenever they have to do anything that the computer could be doing for them. Hence, they develop programs that anticipate their needs and solve problems for them, so that they can do less (there's that laziness again) while accomplishing more.

Finally, hubris is that quality which makes programmers write programs that they want other people to see (and be able to maintain). Hubris is also a quality that promotes innovation: if you think that you have a better way and you're not afraid to prove it, you're often right.

Odd ideas for a culture, perhaps, but effective ones. Here's another tenet of the Perl way: "There's more than one way to do it." What this means is that Perl programmers are a results-oriented lot. They're likely to applaud any tool that gets the job done, regardless of whether or not the code looks like something they would have written. Another side effect of this tenet that particularly endears itself to Win32 Perl programmers is that Perl is highly portable. Although ready-made scripts that you find on the Net may use existing UNIX tools or UNIX system calls that aren't portable to the Windows environment (this scenario has led Win32 programmers to say, "There's more than one way to do it, and it's a good thing, because most of the ways don't work"), you can nearly always find a way to make them work (and nobody will make fun of you if your solution is perhaps somewhat less than elegant).

True to this philosophy, Perl stands for either Practical Extraction and Report Language or Pathologically Eclectic Rubbish Lister (both derivations are sanctioned by the Perl community). Perl for Win32 sprang into existence when Microsoft commissioned ActiveState Tool Corporation (formerly Hip Communications) to do a port for inclusion in the Windows NT Resource Kit. ActiveState is still improving Perl for Win32, extending it with functionality specific to the Win32 platforms, and incorporating the best and most appropriate new features as they are added to the core Perl distribution.

You'll find that Pert for Win32 uses some of the coolest and most compelling technologies available to Windows programmers including OLE automation, ODBC database connectivity, ActiveX scripting, and much more. The source code for Pert (including Pert for Win32) is freely available and freely redistributable. If you want to extend Pert to provide additional features, or embed the interpreter in your own application, you can easily do so.

You'll also find that the Pert community believes in (and practices) information and code sharing. There is an archive network (called the CPAN, for Comprehensive Pert Archive Network), where you can find thousands of existing Pert programs and code fragments.

In addition to a vast body of high quality pre-written code, Pert excels at rapid application development. Part of this is due to the powerful qualities of language that let you do lots Of work with a few statements-another part is due to the Pert development tools themselves.

Perl is an interpreted language, but it might work a little bit differently from other interpreted languages that you've used. Pert is actually both a compiler and an interpreter, When you invoke the Pert interpreter on a Perl script file, the file is first Compiled and optimized, then efficiently executed. Not only does this allow for efficient runtime execution, it also promotes a quick development cycle, in which you can quickly make changes and rerun your script without going through a long compile and link cycle.

In spite of Perl's relatively free syntax, you can easily develop correct Pert programs. Not only is there a Pert debugger, but the compiler itself will issue informative warnings when you're treading on thin ice. Furthermore, the interpreter doesn't execute unless the program compiles completely. This feature saves You from the common interpreted-language nightmare in which the first half of Your program works and does Something to a file, and then the second half doesn't.

Purpose of Perl

Well, you've made it through the Pert hype. You might be wondering why you'd ever use Perl. This section provides a couple of ideas.

You can use Perl for World Wide Web (www) programming. You've probably heard that Pert has become a sort of lingua franca for the Web (actually, you may have heard that statement for more than one language, but we'll say it again here). Pert cannot only be used as a CGI language (for which there are wonderful modules available), but it can be used as an ISAPI extension (an in-process extension to your web server), or even as an ActiveX scripting language. You can also use Perl to validate HTML syntax, to verify that web hyperlinks are still correct, and to fetch URLs from the Internet.

You can use Perl for many system administration chores. Not only will Perl let you manipulate the Registry, the Event Log, and Windows NT user account information, it's also the best tool going for processing log files of nearly any format.

You can use Perl to drive your favorite word processor or spreadsheet using OLE Automation. You can use the freely available Win32::ODBC module or Active Data Objects (ADO) to access your favorite local or enterprise database.

You can use Perl to retrieve (and filter) your email and Usenet news. You can use Perl to send email, interact with FTP and HTTP servers, and be a client for nearly any other type of Internet server you can dream up.

You can use Perl to process textual or numerical data, to prototype projects, to do quick search and replace functions in text files, to drive the execution of a sequence of commands, and much, much more.

In short, Perl can do zillions of thing to help you do your job faster and get back to doing things that are fun (many of which you can also use Perl to do). And along the way, you might find that the journey itself can be a lot of fun.

Like any language, Perl can be "write only"; it's possible to write programs that are impossible to read. But with proper care, you can avoid this common accusation. Yes, sometimes Perl looks like line noise to the uninitiated, but to the seasoned Perl programmer, it looks like checksummed line noise with a mission in life. If you follow the guidelines of this book, your programs should be easy to read and easy to maintain, but they probably won't win any obfuscated Perl contests....

Meet the Author

Erik Olson is a renegade linguist who makes a living developing software for Win32 platforms. Erik is currently the chief technical officer at Axiom Technologies, LC, a software outsourcing shop. Erik delivers developer training, system administration, and program/concept development for a number of large-scale horizontal and vertical applications. Working as a program developer since 1986, Erik has implemented a variety of systems ranging from point-of-sales systems to horizontal PIM products to real-time financial market applications. Although much of his work is done in C++, he has particular interests in Web development and scripting languages. Erik coauthored Learning Perl on Win32 Systems with Tom Christiansen and Randal Schwartz.

Tom Christiansen is a freelance consultant specializing in Perl training and writing. After working for several years for TSR Hobbies (of Dungeons and Dragons fame), he set off for college where he spent a year in Spain and five in America, dabbling in music, linguistics, programming, and some half-dozen different spoken languages. Tom finally escaped UW-Madison with B.A.s in Spanish and computer science and an M.S. in computer science. He then spent five years at Convex as a jack-of-all-trades working on everything from system administration to utility and kernel development, with customer support and training thrown in for good measure. Tom also served two terms on the USENIX Association Board of directors. With over fifteen years' experience in UNIX system administration and programming, Tom presents seminars internationally. Living in the foothills above Boulder, Colorado, surrounded by mule deer, skunks, and the occasional mountain lion and black bear, Tom takes summers off for hiking, hacking, birding, music making, and gaming.

Customer Reviews

Average Review:

Post to your social network


Most Helpful Customer Reviews

See all customer reviews