PERL by Example / Edition 4

Paperback (Print)
Buy New
Buy New from BN.com
$35.28
Used and New from Other Sellers
Used and New from Other Sellers
from $18.74
Usually ships in 1-2 business days
(Save 65%)
Other sellers (Paperback)
  • All (12) from $18.74   
  • New (6) from $30.75   
  • Used (6) from $18.74   

Overview

“I picked up a copy of JavaScript by Example over the weekend and wanted to thank you for putting out a book that makes JavaScript easy to understand. I’ve been a developer for several years now and JS has always been the “monster under the bed,” so to speak. Your book has answered a lot of questions I’ve had about the inner workings of JS but was afraid to ask. Now all I need is a book that covers Ajax and Coldfusion. Thanks again for putting together an outstanding book.”

Chris Gomez, Web services manager, Zunch Worldwide, Inc.

“I have been reading your UNIX ® Shells by Example book, and I must say, it is brilliant. Most other books do not cover all the shells, and when you have to constantly work in an organization that uses tcsh, bash, and korn, it can become very difficult. However, your book has been indispensable to me in learning the various shells and the differences between them…so I thought I’d email you, just to let you know what a great job you have done!”

Farogh-Ahmed Usmani, B.Sc. (Honors), M.Sc., DIC, project consultant (Billing Solutions), Comverse

“I have been learning Perl for about two months now; I have a little shell scripting experience but that is it. I first started with Learning Perl by O’Reilly. Good book but lacking on the examples. I then went to Programming Perl by Larry Wall, a great book for intermediate to advanced, didn’t help me much beginning Perl. I then picked up Perl by Example, Third Edition–this book is a superb, well-written programming book. I have read many computer books and this definitely ranks in the top two, in my opinion. The examples are excellent. The author shows you the code, the output of each line, and then explains each line in every example.”

Dan Patterson, software engineer, GuideWorks, LLC

“Ellie Quigley has written an outstanding introduction to Perl, which I used to learn the language from scratch. All one has to do is work through her examples, putz around with them, and before long, you’re relatively proficient at using the language. Even though I’ve graduated to using Programming Perl by Wall et al., I still find Quigley’s book a most useful reference.”

Casey Machula, support systems analyst, Northern Arizona University, College of Health and Human Services

“When I look at my bookshelf, I see eleven books on Perl programming. Perl by Example, Third Edition, isn’t on the shelf; it sits on my desk, where I use it almost daily. When I bought my copy I had not programmed in several years and my programming was mostly in COBOL so I was a rank beginner at Perl. I had at that time purchased several popular books on Perl but nothing that really put it together for me. I am still no pro, but my book has many dog-eared pages and each one is a lesson I have learned and will certainly remember. “I still think it is the best Perl book on the market for anyone from a beginner to a seasoned programmer using Perl almost daily.”

Bill Maples, network design tools and automations analyst, Fidelity National Information Services

“We are rewriting our intro to OS scripting course and selected your text for the course. It’s an exceptional book. The last time we considered it was a few years ago (second edition). The debugging and system administrator chapters at the end nailed it for us.”

Jim Leone, Ph.D., professor and chair, Information Technology, Rochester Institute of Technology

“Quigley’s book acknowledges a major usage of PHP. To write some kind of front end user interface program that hooks to a back end MySQL database. Both are free and open source, and the combination has proved popular. Especially where the front end involves making an HTML web page with embedded PHP commands. “Not every example involves both PHP and MySQL. Though all examples have PHP. Many demonstrate how to use PHP inside an HTML file. Like writing user-defined functions, or nesting functions. Or making or using function libraries. The functions are a key idea in PHP, that take you beyond the elementary syntax. Functions also let you gainfully use code by other PHP programmers. Important if you are part of a coding group that has to divide up the programming effort in some manner.”

Dr. Wes Boudville, CTO, Metaswarm Inc.

The World’s Easiest Perl Tutorial–Fully Updated!

Perl by Example, Fourth Edition, is the easiest, most hands-on way to learn Perl. Legendary Silicon Valley programming instructor Ellie Quigley has thoroughly updated her classic to deliver the skills and information today’s Perl users need most–including all-new coverage of MySQL database programming and a Perl QuickStart designed to get experienced users up and running fast.

Quigley illuminates every technique with focused, classroom-tested code examples, detailed line-by-line explanations, and real program output. This exceptionally clear, easy-to-understand book takes you from your first Perl script to database-driven applications. It’s the only Perl book you’ll ever need!

New in this edition:

  • Perl programming QuickStart: makes first-time Perl programmers productive in just twenty pages
  • All-new chapter on using the Perl DBI with the MySQL database–plus an easy SQL primer to quickly get you started programming any database
  • New introductions to Perl in biology (bioinformatics) and to mod_perl, a Perl interpreter embedded in the Apache server, which allows you to create fast, dynamic content; manage the Apache server; authenticate users; and much more

Completely updated:

  • Includes many new and completely rewritten code examples
  • Contains fully revised CGI coverage for building dynamic Web sites with Perl
  • Covers modern Perl 5.8 concepts and principles–and provides a great foundation for Perl 6

More than 30,000 sysadmins, power users, and developers have used previous editions of Perl by Example

to become expert Perl programmers. With Perl by Example, Fourth Edition, you can, too–even if you’re

completely new to Perl. After you’ve become an expert, you’ll turn to this book constantly as the best

source for reliable answers, solutions, and code.

About the CD-ROM:

The CD-ROM includes all code and files for this book’s hundreds of example scripts.

Read More Show Less

Product Details

  • ISBN-13: 9780132381826
  • Publisher: Prentice Hall
  • Publication date: 11/16/2007
  • Edition description: Fourth Edition
  • Edition number: 4
  • Pages: 971
  • Sales rank: 371,960
  • Product dimensions: 7.00 (w) x 9.30 (h) x 2.10 (d)

Meet the Author

Ellie Quigley has taught scripting languages in Silicon Valley for more than twenty years. Her Perl and shell programming classes at the University of Santa Cruz Extension program have become part of Silicon Valley lore. Her best-selling books include UNIX ® Shells by Example, Fourth Edition; PHP and MySQL by Example (with coauthor Marko Gargenta); and JavaScript by Example, all from Prentice Hall.

Read More Show Less

Read an Excerpt

You may wonder, why a new edition of Perl by Example? Perl 5 hasn’t really changed that much; in fact, it’s changed very little at all since the third edition of this book was published. And since Perl 6 hasn’t been officially released, why not wait? Well, consider this. Let’s say you bought a new Whirlpool washing machine six years ago. It’s running perfectly. But since then, the mounds of laundry washed by that machine have come and gone. Now you’re sporting a new trendy fashion, you have designer sheets and towels, and the detergent brand you use is hypoallergenic, nontoxic, and biodegradable, not available when you bought the washer. Even though Perl 5 has changed very little, the computer world has. It is always in a flux of new innovations, technologies, applications, and fads, and programs are being written to accommodate those changes. Whether analyzing data from the GenBank sequence database, writing applications for an iPhone, creating a personal blog on “myspace,” or adjusting to the changes in a new Vista version of Windows, some computer program is involved, and very possibly it is a Perl program. Whatever the case, we like to keep up with the times. This new edition of Perl by Example was written for just that purpose.

As we speak, I am teaching Perl at the UCSC1 extension in Sunnyvale, California, to a group of professionals coming from all around the Silicon Valley. I always ask at the beginning of a class, “So why do you want to learn Perl?” The responses vary from, “Our company has an auction site on the Web and I’m the webmaster. I need to use Perl and Apache to process our order information and send it to Oracle,” or “I work in a genetics research group at Stanford and have to sift through and analyze masses of data, and I heard that if I learn Perl, I won’t have to depend on programmers to do this,” or “I’m a UNIX/Linux system administrator and our company has decided that all admin scripts should be converted to Perl,” or “I just got laid off and heard that it’s an absolute must to have Perl on my resume.” And I am always amazed at the variety of people who show up: engineers, scientists, geneticists, meteorologists, managers, salespeople, programmers, techies, hardware guys, students, stockbrokers, administrators of all kinds, librarians, authors, bankers, artists—you name it. Perl does not exclude anyone. Perl is for everyone and it runs on everything.

No matter who you are, I think you’ll agree that a picture is worth a thousand words, and so is a good example. Perl by Example is organized to teach you Perl from scratch with examples of complete, succinct programs. Each line of a script example is numbered, and important lines are highlighted in bold. The output of the program is then displayed with line numbers corresponding to the script line numbers. Following the output is a separate explanation for each of the numbered lines. The examples are small and to the point for the topic at hand. Since the backbone of this book was used as a student guide to a Perl course, the topics are modularized. Each chapter builds on the previous one with a minimum of forward referencing and a logical progression from one topic to the next. There are exercises at the end of the chapters. You will find all of the examples on the CD at the back of the book. They have been thoroughly tested on a number of major platforms.

Perl by Example is not just a beginner’s guide but a complete guide to Perl. It covers many aspects of what Perl can do, from regular expression handling, to formatting reports, to interprocess communication. It will teach you about Perl and, in the process, a lot about UNIX and Windows. Since Perl was originally written on and for UNIX systems, some UNIX knowledge will greatly accelerate your learning curve, but it is not assumed that you are by any means a guru. Anyone reading, writing, or just maintaining Perl programs can greatly profit from this text.

Perl has a rich variety of functions for handling strings, arrays, the system interface, networking, and more. In order to understand how these functions work, background information concerning the hows, whys, and what-fors is provided before demonstrating functional sample programs. This eliminates continually wading through manual pages and other books to understand what is going on, what the arguments mean, and what the function actually does.

The appendices contain a complete list of functions and definitions, command-line switches, special variables, popular modules, and the Perl debugger; a bioinformatics tutorial to introduce BioPerl, and a tutorial covering mod_perl, the fast way to create server side Perl scripts that replace the need for the Common Gateway Interface.

I have been teaching for the past thirty years and am committed to understanding how people learn. Having taught Perl now for more than 14 years, all over the world, I find that many new Perlers get frustrated when trying to teach themselves how to program. Most people seem to learn best from succinct little examples and practice. So I wrote a book to help myself learn and to help my students, and now to help you. As Perl has grown, so have my books. This latest, fourth, edition includes a new chapter on Perl and DBI with MySQL, a revised chapter on Perl objects, and new examples and explanations for the rest of the chapters to keep things current and interesting. The appendix material has been revised to include BioPerl and mod_perl. In this book, you will not only learn Perl, but also save yourself a great deal of time. At least that’s what my students and readers have told me. You be the judge.

Note:
1. University of California, Santa Cruz.

Read More Show Less

Table of Contents

Preface xxvii

Chapter 1: The Practical Extraction and Report Language 1

1.1 What Is Perl? 1

1.2 What Is an Interpreted Language? 2

1.3 Who Uses Perl? 3

1.4 Where to Get Perl 5

1.5 What Is CPAN? 9

1.6 Perl Documentation 10

1.7 What You Should Know 12

1.8 What’s Next? 12

Chapter 2: Perl Quick Start 13

2.1 Quick Start, Quick Reference 13

2.2 Chapter Summary 29

2.3 What’s Next? 29

Chapter 3: Perl Scripts 31

3.1 Script Setup 31

3.2 The Script 32

3.3 Perl at the Command Line 39

3.4 What You Should Know 43

3.5 What’s Next? 43

Chapter 4: Getting a Handle on Printing 45

4.1 The Filehandle 45

4.2 Words 45

4.3 The print Function 46

4.4 The printf Function 59

4.5 What You Should Know 66

4.6 What’s Next? 66

Chapter 5: What’s in a Name 69

5.1 About Perl Variables 69

5.2 Scalars, Arrays, and Hashes 77

5.3 Reading from STDIN 94

5.4 Array Functions 100

5.5 Hash (Associative Array) Functions 118

5.6 More Hashes 128

5.7 What You Should Know 132

5.8 What’s Next? 133

Chapter 6: Where’s the Operator? 137

6.1 About Perl Operators 137

6.2 Mixing Data Types 138

6.3 Precedence and Associativity 139

6.4 What You Should Know 168

6.5 What’s Next? 168

Chapter 7: If Only, Unconditionally, Forever 171

7.1 Control Structures, Blocks, and Compound Statements 171

7.2 Repetition with Loops 177

7.3 What You Should Know 200

7.4 What’s Next? 200

Chapter 8: Regular Expressions–Pattern Matching 203

8.1 What Is a Regular Expression? 203

8.2 Expression Modifiers and Simple Statements 204

8.3 Regular Expression Operators 210

8.4 What You Should Know 232

8.5 What’s Next? 232

Chapter 9: Getting Control–Regular Expression Metacharacters 235

9.1 Regular Expression Metacharacters 235

9.2 Unicode 281

9.3 What You Should Know 283

9.4 What’s Next? 283

Chapter 10: Getting a Handle on Files 285

10.1 The User-Defined Filehandle 285

10.2 Passing Arguments 310

10.3 File Testing 319

10.4 What You Should Know 321

10.5 What’s Next? 322

Chapter 11: How Do Subroutines Function? 325

11.1 Subroutines/Functions 325

11.2 Passing Arguments 330

11.3 Call-by-Reference 344

11.4 What You Should Know 358

11.5 What’s Next? 359

Chapter 12: Modularize It, Package It, and Send It to the Library! 363

12.1 Packages and Modules 363

12.2 The Standard Perl Library 370

12.3 Modules from CPAN 390

12.4 What You Should Know 398

12.5 What’s Next? 398

Chapter 13: Does This Job Require a Reference? 401

13.1 What Is a Reference? What Is a Pointer? 401

13.2 What You Should Know 420

13.3 What’s Next? 420

Chapter 14: Bless Those Things! (Object-Oriented Perl) 423

14.1 The OOP Paradigm 423

14.2 Classes, Objects, and Methods 425

14.3 Anonymous Subroutines, Closures, and Privacy 453

14.4 Inheritance 460

14.5 Public User Interface–Documenting Classes 474

14.6 Using Objects from the Perl Library 479

14.7 What You Should Know 484

14.8 What’s Next? 485

Chapter 15: Those Magic Ties and DBM Stuff 493

15.1 Tying Variables to a Class 493

15.2 DBM Files 505

15.3 What You Should Know 512

15.4 What’s Next? 512

Chapter 16: CGI and Perl: The Hyper Dynamic Duo 513

16.1 Static and Dynamic Web Pages 513

16.2 How It all Works 516

16.3 Creating a Web Page with HTML 522

16.4 How HTML and CGI Work Together 526

16.5 Getting Information Into and Out of the CGI Script 531

16.6 CGI and Forms 535

16.7 The CGI.pm Module 559

Chapter 17: Perl Meets MySQL–A Perfect Connection 603

17.1 Introduction 603

17.2 What Is a Relational Database? 604

17.3 Getting Started with MySQL 613

17.4 What Is the Perl DBI? 638

17.5 Statements that Don’t Return Anything 666

17.6 Transactions 670

17.7 Using CGI and the DBI to Select and Display Entries 672

17.8 What’s Left? 678

17.9 What You Should Know 679

17.10What’s Next? 679

Chapter 18: Interfacing with the System 685

18.1 System Calls 685

18.2 Processes 721

18.3 Other Ways to Interface with the Operating System 747

18.4 Error Handling 755

18.5 Signals 760

18.6 What You Should Know 764

18.7 What’s Next? 765

Chapter 19: Report Writing with Pictures 767

19.1 The Template 767

19.2 What You Should Know 783

19.3 What’s Next? 783

Chapter 20: Send It Over the Net and Sock It to ’Em! 785

20.1 Networking and Perl 785

20.2 Client /Server Model 785

20.3 Network Protocols (TCP/IP) 785

20.4 Network Addressing 787

20.5 Sockets 794

20.6 Client /Server Programs 800

20.7 The Socket.pm Module 808

20.8 What You Should Know 813

Appendix A: Perl Built-ins, Pragmas, Modules, and the Debugger 815

A.1 Perl Functions 815

A.2 Special Variables 845

A.3 Perl Pragmas 848

A.4 Perl Modules 850

A.5 Command-Line Switches 856

A.6 Debugger 858

Appendix B: SQL Language Tutorial 863

B.1 What Is SQL? 863

B.2 SQL Data Manipulation Language (DML) 871

B.3 SQL Data Definition Language 888

B.4 SQL Functions 901

B.5 Appendix Summary 910

B.6 What You Should Know 910

Appendix C: Perl and Biology 915

C.1 What Is Bioinformatics? 915

C.2 A Little Background on DNA 915

C.3 Some Perl Examples 917

C.4 What Is BioPerl? 919

C.5 Resources 923

Appendix D: Power and Speed: CGI and mod_perl 925

D.1 What Is mod_perl? 925

D.2 The mod_perl Web Site 927

D.3 Installing mod_perl 928

D.4 Resources 938

Index 939

Read More Show Less

Preface

You may wonder, why a new edition of Perl by Example? Perl 5 hasn’t really changed that much; in fact, it’s changed very little at all since the third edition of this book was published. And since Perl 6 hasn’t been officially released, why not wait? Well, consider this. Let’s say you bought a new Whirlpool washing machine six years ago. It’s running perfectly. But since then, the mounds of laundry washed by that machine have come and gone. Now you’re sporting a new trendy fashion, you have designer sheets and towels, and the detergent brand you use is hypoallergenic, nontoxic, and biodegradable, not available when you bought the washer. Even though Perl 5 has changed very little, the computer world has. It is always in a flux of new innovations, technologies, applications, and fads, and programs are being written to accommodate those changes. Whether analyzing data from the GenBank sequence database, writing applications for an iPhone, creating a personal blog on “myspace,” or adjusting to the changes in a new Vista version of Windows, some computer program is involved, and very possibly it is a Perl program. Whatever the case, we like to keep up with the times. This new edition of Perl by Example was written for just that purpose.

As we speak, I am teaching Perl at the UCSC 1 extension in Sunnyvale, California, to a group of professionals coming from all around the Silicon Valley. I always ask at the beginning of a class, “So why do you want to learn Perl?” The responses vary from, “Our company has an auction site on the Web and I’m the webmaster. I need to use Perl and Apache to process our order information and send it to Oracle,” or “I work in a genetics research group at Stanford and have to sift through and analyze masses of data, and I heard that if I learn Perl, I won’t have to depend on programmers to do this,” or “I’m a UNIX/Linux system administrator and our company has decided that all admin scripts should be converted to Perl,” or “I just got laid off and heard that it’s an absolute must to have Perl on my resume.” And I am always amazed at the variety of people who show up: engineers, scientists, geneticists, meteorologists, managers, salespeople, programmers, techies, hardware guys, students, stockbrokers, administrators of all kinds, librarians, authors, bankers, artists—you name it. Perl does not exclude anyone. Perl is for everyone and it runs on everything.

No matter who you are, I think you’ll agree that a picture is worth a thousand words, and so is a good example. Perl by Example is organized to teach you Perl from scratch with examples of complete, succinct programs. Each line of a script example is numbered, and important lines are highlighted in bold. The output of the program is then displayed with line numbers corresponding to the script line numbers. Following the output is a separate explanation for each of the numbered lines. The examples are small and to the point for the topic at hand. Since the backbone of this book was used as a student guide to a Perl course, the topics are modularized. Each chapter builds on the previous one with a minimum of forward referencing and a logical progression from one topic to the next. There are exercises at the end of the chapters. You will find all of the examples on the CD at the back of the book. They have been thoroughly tested on a number of major platforms.

Perl by Example is not just a beginner’s guide but a complete guide to Perl. It covers many aspects of what Perl can do, from regular expression handling, to formatting reports, to interprocess communication. It will teach you about Perl and, in the process, a lot about UNIX and Windows. Since Perl was originally written on and for UNIX systems, some UNIX knowledge will greatly accelerate your learning curve, but it is not assumed that you are by any means a guru. Anyone reading, writing, or just maintaining Perl programs can greatly profit from this text.

Perl has a rich variety of functions for handling strings, arrays, the system interface, networking, and more. In order to understand how these functions work, background information concerning the hows, whys, and what-fors is provided before demonstrating functional sample programs. This eliminates continually wading through manual pages and other books to understand what is going on, what the arguments mean, and what the function actually does.

The appendices contain a complete list of functions and definitions, command-line switches, special variables, popular modules, and the Perl debugger; a bioinformatics tutorial to introduce BioPerl, and a tutorial covering mod_perl, the fast way to create server side Perl scripts that replace the need for the Common Gateway Interface.

I have been teaching for the past thirty years and am committed to understanding how people learn. Having taught Perl now for more than 14 years, all over the world, I find that many new Perlers get frustrated when trying to teach themselves how to program. Most people seem to learn best from succinct little examples and practice. So I wrote a book to help myself learn and to help my students, and now to help you. As Perl has grown, so have my books. This latest, fourth, edition includes a new chapter on Perl and DBI with MySQL, a revised chapter on Perl objects, and new examples and explanations for the rest of the chapters to keep things current and interesting. The appendix material has been revised to include BioPerl and mod_perl. In this book, you will not only learn Perl, but also save yourself a great deal of time. At least that’s what my students and readers have told me. You be the judge.

Note:
1. University of California, Santa Cruz.

Read More Show Less

Customer Reviews

Average Rating 4
( 1 )
Rating Distribution

5 Star

(0)

4 Star

(1)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing 1 Customer Reviews
  • Anonymous

    Posted November 22, 2007

    A reviewer

    [A review of the 4th Edition, that came out in late 2007.] One way to learn is to learn by example. Quigley follows this precept in this massive book on Perl. Candidly, there are far slimmer books that describe the syntax of Perl. Typically, these have a few didactic examples. For some people, that suffices. But you might be a newbie to any type of programming. Or perhaps you want a grab bag of many example programs, to search thru in case you can find one to quickly adapt to your needs. In this case, Quigley's book might be well suited. The examples are easy to grasp. Accompanied by exhaustive supporting text. It doesn't get simpler than this. In some ways, this led to complaints in reviews of earlier editions. A few other reviewers saw the examples as perhaps too trivial. Well they are, to experienced programmers. Newcomers need more support. The book also goes into an important usage context. Where you combine Perl scripts with CGI to write dynamic web pages. But beware. The book doesn't really discuss on first principles whether you should use this Perl/CGI combination. CGI has been found to be rather cumbersome for dynamic pages. Programmers tend to favour other methods, like JSP [Java Server Pages] and ASP.

    Was this review helpful? Yes  No   Report this review
Sort by: Showing 1 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)