did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

We're the #1 textbook rental company. Let us show you why.

9780130089656

Modern Perl Programming

by
  • ISBN13:

    9780130089656

  • ISBN10:

    0130089656

  • Edition: 1st
  • Format: Paperback
  • Copyright: 2002-02-04
  • Publisher: Prentice Hall
  • Purchase Benefits
  • Free Shipping Icon Free Shipping On Orders Over $35!
    Your order must be $35 or more to qualify for free economy shipping. Bulk sales, PO's, Marketplace items, eBooks and apparel do not qualify for this offer.
  • eCampus.com Logo Get Rewarded for Ordering Your Textbooks! Enroll Now
List Price: $44.99
We're Sorry.
No Options Available at This Time.

Summary

Supercharged Perl programming for every developer, sysadmin, and Web professional. In-depth coverage of references-the cornerstone of advanced Perl programming Complete application examples, not just code snippets CGI, networking, GUIs, and object development Enterprise database integration applicable to all databases including Oracle and Sybase Modern Perl Programming will help you master Perl's most robust, powerful features-so you can make the most of the language whether you're a beginner or an experienced scripter. Michael Saltzman starts with a rapid-fire Perl tutorial and refresher. Then, using actual applications-not just code snippets-he presents expert guidance on the Perl features that deliver the most power, productivity, and efficiency.Coverage includes: Practical coverage of data types, I/O, control structures, and operators Making the most of associative arrays, hash tables, and regular expressions Building your own subroutines Developing Web-based CGI and network applications Example-rich coverage of references (pointers)-the cornerstone of advanced Perl development Object-oriented programming, data structures, and advanced GUI development Integrating with enterprise-class databases: detailed examples applicable to Oracle and Sybase and other databases Debugging Perl applications Includes extensive downloadable library of code samples! You won't just get results fast: You'll get great results fast-robust, maintainable, industrial-strength Perl for even the most challenging environments.

Author Biography

MICHAEL SALTZMAN is the founder of /training/etc Inc. He has developed extensive course materials, including courses in Perl, C/C++/STL, and Java and has led a wide variety of technical seminars on programming languages and UNIX. Before pursuing a career as a technical lecturer and writer, he was employed for 23 years by the National Security Agency, where he taught a wide range of programming and UNIX system administration courses. He holds MS degrees in Computer Science from the American University and Johns Hopkins University.

Table of Contents

Preface xvii
What Is Perl? xvii
Why program in Perl? xvii
Why did I write this book? xviii
Who should read this book? xviii
Overview of the Book xviii
Chapter Summaries xviii
A Perl Tutorial xviii
Simple I/O xviii
Perl Operators xviii
Arrays and Array Functions xix
Hashes xix
Regular Expressions xix
Subprograms xix
Generating Reports in Perl xix
Accessing System Resources xx
Perl References xx
Object-Oriented Programming xx
Client/Server Applications xx
CGI Applications xx
Graphical User Interfaces with the Tk. pm Module xx
Accessing Real Databases in Perl xx
Debugging Perl Scripts xxi
Conventions Used in this Book xxi
Spelling xxi
Fonts xxi
Unix vs. Windows xxi
Filenames for Perl scripts xxii
User input xxii
Displaying programs xxii
Standard input and standard output redirections xxiii
The newline character xxiii
Writing style xxiv
Displaying files xxiv
Source files xxiv
Acknowledgments xxiv
A Tutorial Introduction to Perl
1(28)
Getting Started
1(5)
The first Perl program
2(2)
Some elementary I/O
4(2)
Perl Variables
6(8)
Scalars
7(1)
Arrays
7(2)
Array functions
9(2)
Arrays and STDIN
11(1)
Associative arrays
12(2)
Control Flow Constructs
14(4)
if else, elsif
14(1)
unless
15(1)
while
15(1)
until
16(1)
for
16(1)
foreach
17(1)
Statement modifiers
17(1)
What is true and what is false?
18(1)
Altering Loop Control Flow
18(3)
last
18(2)
next
20(1)
redo
20(1)
Labeled blocks
20(1)
A Few Special Perl Variables
21(1)
$_
21(1)
$
22(1)
Regular Expressions
22(2)
Pattern matching
22(2)
Substitutions
24(1)
Writing Your Own Functions
24(5)
Exercises
27(2)
Input and Output in Perl
29(20)
Filehandles
29(6)
Builtin filehandles
29(2)
The print function
31(1)
The print f function
32(2)
sprint f
34(1)
Creating Your Own Filehandles
35(5)
Open
35(2)
die
37(1)
Closing files
38(1)
Pipes
38(1)
Opening pipe files
38(2)
File Operators
40(1)
The stat Function
41(1)
Other Filehandles
42(7)
The ARGV filehandle
42(1)
The eof function
43(1)
The null filehandle: <>
44(1)
The Data filehandle
45(2)
Exercises
47(2)
Operators in Perl
49(20)
Perl Operators
49(20)
Assignment operators
52(1)
Increment and decrement operators
52(2)
Modulus (remainder) operator
54(1)
Conditional expression
54(1)
Range operator
55(1)
String operators
56(1)
Relational operators
57(2)
Logical operators
59(1)
Bit manipulation operators
60(1)
Regular expression operators
61(1)
Some string functions
62(2)
The comma operator
64(3)
Exercises
67(2)
Arrays and Array Functions
69(18)
Introduction
69(5)
Arrays are dynamic
69(2)
Treating an array in a scalar context
71(1)
Selecting an element from an array
71(1)
Arrays and lists
72(1)
Array slices
73(1)
The @ARGV Array
74(1)
Array Functions
74(13)
push and pop
75(1)
shift and unshift
75(1)
reverse
76(1)
split
77(1)
join
78(1)
sort
79(3)
grep
82(1)
splice
83(2)
Exercises
85(2)
Hashes
87(18)
Introduction
87(7)
Hashes as dual arrays
88(1)
A hashing algorithm
89(3)
Builtin hashing
92(2)
Sorting Hashes
94(2)
Sorting by keys
94(1)
Sorting by values
94(2)
Hash Solutions to Common Problems
96(4)
Finding unique words in a file
96(1)
Reverse lookups
96(2)
Selecting the top n elements from a list
98(2)
Bultin Associative Arrays
100(1)
The %ENV hash
100(1)
The %INC hash
101(1)
Reading from a File into a Hash
101(4)
Exercises
103(2)
Regular Expressions
105(20)
Introduction
105(1)
The Match Operator
105(2)
Regular Expression Metacharacters
107(3)
Single-character matches
107(1)
Within square brackets
108(1)
Multiple-character matches
109(1)
Other special symbols
110(1)
Anchoring Patterns
110(2)
Remembering Parts of Matches
112(2)
Greedy Regular Expressions
114(1)
Substitutions
114(4)
The g modifier
115(1)
The i modifier
116(1)
The e modifier
117(1)
The m modifier
117(1)
Backtracking
118(1)
The tr Operator
118(7)
Exercises
123(2)
Subprograms
125(22)
Introduction
125(2)
Organization of subroutines
125(2)
Passing Arguments to Subroutines
127(6)
local vs. my
129(1)
Typeglobs
129(4)
Returning Values from Subroutines
133(4)
Returning a scalar
133(2)
Returning an array
135(2)
Returning other types
137(1)
Perl Libraries
137(2)
The require function
137(1)
The @INC array
138(1)
The Perl Standard Library
139(1)
Packages
139(3)
Modules and use
141(1)
Predefined Subroutines
142(5)
Exercises
145(2)
Generating Reports in Perl
147(12)
Introduction
147(1)
format
148(4)
A different view
150(1)
Multi-line formattin
151(1)
Top-of-page formatting
152(2)
The select Function
154(1)
Special formatting variables: $ ∼ and $ˆ
154(1)
Bottom-of-Page Formatting
155(4)
Exercises
157(2)
Accessing System Resources
159(16)
Introduction
159(1)
File and Directory System Calls
159(4)
mkdir
160(1)
chdir
160(1)
opendir, readdir, and closedir
161(1)
unlink and rename
162(1)
Process Creation
163(4)
exec
163(1)
fork and wait
164(1)
system
165(1)
Back quotes
165(2)
Updating Files
167(8)
tell
167(1)
seek
168(1)
Modifying records
169(4)
Exercises
173(2)
Perl References
175(26)
Introduction
175(8)
What is a reference?
175(1)
Scalar references
176(1)
Array references
176(2)
Prototypes
178(1)
Hash references
179(1)
A relaxed notation
180(1)
References to subroutines
181(2)
Anonymous References
183(1)
Anonymous arrays
183(1)
Anonymous hashes
183(1)
Anonymous scalars
184(1)
Complex Data Structures
184(8)
Two-dimensional arrays
184(3)
Complex hashes
187(1)
Two-dimensional hashes
188(4)
Collections of Records
192(9)
Sorting based on a key field
194(1)
References to references
195(4)
Exercises
199(2)
Object-Oriented Programming
201(16)
Introduction
201(1)
The Vocabulary of Object Orientation
201(1)
Defining and Using Objects
202(9)
Information hiding
205(1)
Accessor and mutator methods
206(1)
Other instance methods
207(1)
Writing an accessor and a mutator as one method
207(1)
Destructors
208(1)
Class methods
209(2)
Inheritance
211(6)
Super
211(2)
Polymorphism
213(2)
Exercises
215(2)
Client/Server Applications
217(14)
Introduction
217(3)
TCP networks
217(1)
Internet addresses
218(1)
Ports
218(1)
Sockets
218(2)
Socket. pm
220(1)
Writing Clients
220(4)
A daytime client
220(1)
An echo client
221(1)
An FTP client
222(2)
Writing Servers
224(3)
A daytime server
224(2)
An expression server
226(1)
Iterative Servers
227(4)
Exercises
229(2)
CGI Programming with Perl
231(22)
Introduction
231(2)
CGI languages
231(1)
HTML forms
232(1)
Web servers
233(1)
Web browsers
233(1)
Starting a CGI program
233(1)
HTML and Forms
233(6)
Form tags
235(1)
Get method vs. Post Method
236(2)
HTML form element names
238(1)
URL encoding
238(1)
Relationship between Server and CGI Script
239(5)
A Perl CGI script
239(3)
Here strings
242(1)
Environment variables
243(1)
cgi-lib.pl and cgi.pm
244(1)
CGI Scripts and Databases
244(9)
Exercises
251(2)
Graphical User Interfaces with the TK. PM Module
253(34)
Introduction
253(4)
Widgets
254(1)
Event-driven programming
254(1)
A simple example
255(2)
Geometry Management
257(5)
pack
257(3)
grid
260(1)
place: Absolute coordinates
261(1)
Buttons
262(4)
Images/Bitmaps
262(1)
Button callbacks
263(1)
The checkbutton widget
263(2)
Radio buttons
265(1)
Other Widgets
266(12)
The Entry widget
267(1)
List boxes
268(2)
text widget
270(1)
Scrollbars
271(2)
Dialog boxes
273(2)
Menus
275(3)
Frames
278(4)
Top-level windows
280(2)
Binding
282(5)
Exercise
285(2)
Accessing Real Databases in Perl
287(20)
Introduction
287(2)
What is DBI?
288(1)
What is DBD?
288(1)
The DBI architecture
288(1)
A Review of SQL and Relational Databases
289(3)
Accessing a relational database
290(1)
Retrieving data from a relational database
291(1)
Data modification commands
292(1)
Accessing a Database from Perl
292(7)
Database handles
292(1)
Executing a query
293(1)
Binding output columns
294(1)
Accessing database metadata
295(2)
Dynamic requests
297(2)
Adding a Graphical Front-End
299(4)
Accessing a Real Database via a Web Form
303(4)
Debugging Perl Scripts
307(24)
Introduction
307(1)
Using the print Function
307(4)
The warn function
308(1)
The eval function
309(2)
Command-Line Options
311(2)
The -c option
311(1)
The -e option
311(1)
The -n option
312(1)
The -v option
312(1)
The -w option
312(1)
Executing Portions of Your Code
313(5)
The -x option
314(1)
The _END_word
314(1)
The Data filehandle
315(1)
Documenting Perl code
316(2)
Quoting
318(2)
Useful Perl Modules
320(4)
strict.pm
320(1)
strict vars
320(1)
strict refs
321(1)
strict subs
322(1)
diagnostics.pm
323(1)
Carp.pm
323(1)
The Perl Debugger
324(1)
Useful Perl Function
325(6)
The ord function
325(1)
The chr function
326(1)
The hex and oct functions
327(1)
pack and unpack
327(4)
Index 331

Supplemental Materials

What is included with this book?

The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.

The Used, Rental and eBook copies of this book are not guaranteed to include any supplemental materials. Typically, only the book itself is included. This is true even if the title states it includes any access cards, study guides, lab manuals, CDs, etc.

Excerpts

PrefaceWelcome to the world of Perl programming. I know that few of you enjoy reading the preface, but it may help to at least browse through it to make the reading of the actual text a little easier. In this section I will tell you a little about Perl and a lot about conventions used in this book. But first, I have a few questions to answer. What Is Perl?Perl is a programming language that was created by Larry Wall in the early 1980s. The language has gained widespread popularity over the last few decades. In the beginning, Perl was used by a small group of Unix system administrators who needed a language, superior to the Unix shell, to do various system administration tasks. With the exponential growth of the Internet and the popularity of the World Wide Web's Common Gateway Interface (CGI) programming paradigm, the number of Perl programmers has also grown exponentially. Why program in Perl?Being familiar with many programming languages, I'm in a good position to judge them. I have had my favorite languages throughout the years: Fortran, PL/1, C, C++, Java, and of course, Perl. Too many people argue about which language is the best. No language can be all things to all people. Each language has its strengths and weaknesses. However, no language that I know has the expressive capability and ease of use of Perl. You, of course, can decide for yourself when you finish reading this book. Why did I write this book?I have been an instructor of computer programming languages for more than three decades. In that time, I have had the occasion to learn many languages. My typical approach would be to buy a book on the subject, plow through it, and write as many programs as I could to test out various features of the language.I'm very critical of textbooks. Most of the textbooks that I've read never seem to be at the correct level. Half of them seemed too elementary; the other half seemed too advanced. I always wanted one that was right in the middle. I've tried to write this book for the intermediate audience because I think I can save people in that category a lot of time and research. Who should read this book?This is a book about Perl programming, so anybody who is interested in writing Perl programs should read this book. Since Perl is a programming language, you would think this means only programmers should read it. Currently, however, there is a blur over who is a programmer. Many Web-sters who maintain Web pages also write CGI scripts. System administrators need to write scripts to support users. Managers periodically want to write scripts to create reports for various staff members above and below them in the corporate hierarchy. All these groups would profit from reading this book. Overview of the BookThe book is organized in three sections: beginning, intermediate, and advanced. In the beginning section, you will see topics such as: input and output, operators, arrays, control structures, and data types. In the intermediate section, you will see topics such as: associative arrays, regular expressions, subroutines, report writing, and accessing system resources. The advanced section includes topics such as: references, object-oriented programming, client/server programming, CGI programming, graphical user interfaces (GUIs) with the Tk module, accessing real databases in Perl, and debugging. Chapter Summaries Chapter 1: A Perl Tutorial-- demonstrates many fundamental Perl features so that you can start writing Perl programs quickly. Subsequent chapters will drill more deeply into each of the topics presented here. Chapter 2: Simple I/O-- looks more deeply into reading and writing files. Some of Perl's operators for determining the type of a file are explored. Finally, this chapter looks at how you can determine information about files. Chapter 3: Perl Operators

Rewards Program