Manning Logo
Home | Ordering Info | Shopping Cart | Manage My Account | Login
Attention customers: online shopping is now available exclusively through our main website: http://www.manning.com. Thank you.
Elements of Programming with Perl

Inside the book

Sample chapters Table of Contents Errata Index Preface Book Reviews Source Code Author Online

Manning Blog

Why small is sweet?

Author Blogs

Dave Crane more...

Author Calendar

Upcoming Events

Catalog

Java .NET Perl XML All by Subject All by Title

About...

Manning Contact Us Ordering FAQs ebooks Covers Sandbox Forums Distributors Manning Early Access Program (MEAP) Affiliate Program Academia/Publicity User Group Program Press Releases Jobs

Manning Publications Co.
209 Bruce Park Avenue
Greenwich, CT 06830

Elements of Programming with Perl
Andrew L. Johnson

1999 | 368 pages
ISBN: 1884777805
$34.95 Softbound print book  

Table of Contents

preface xi

acknowledgments xv

I Introductory elements

1 Introduction 3

   1.1   On programming 4

   1.2   On Perl 7
      Getting started 10, Running Perl 11, Getting help 12

   1.3   A bigger picture 15

2 Writing code 18

   2.1   Structure 20

   2.2   Naming 21

   2.3   Comments 24

   2.4   Being strict 29

   2.5   A quick style guide 31

3 Writing programs 32

   3.1   A first program 34
      Specification 34, Design 35, Coding 40, Testing and debugging 45, Maintenance 47

   3.2   faqgrep 49

   3.3   Exercises 55

II Essential elements

4 Data: types and variables 59

   4.1   Scalar data 60
      Scalar variables 63

   4.2   Expressions 65

   4.3   List data 67
      Array variables 69, Hash variables 71

   4.4   Context 73

   4.5   References to variables 74

   4.6   Putting it together 76

   4.7   Exercises 77

5 Control structures 78

   5.1   Selection statements 80

   5.2   Repetition: loops 84

   5.3   Logical operators 89

   5.4   Statement modifiers 92

   5.5   Putting it together 92

   5.6   Exercises 97

6 Simple I/O and text processing 98

   6.1   File handles 99

   6.2   Pattern matching 103
      Matching constructs 105, Regex language constructs 107, Matching and substitution operators 112

   6.3   Split and join 113

   6.4   The DATA file handle 114

   6.5   Putting it together 116

   6.6   Exercises 120

7 Functions 121

   7.1   Scope 123

   7.2   Global variables 127

   7.3   Parameters 127

   7.4   Return values 129

   7.5   Designing functions 131

   7.6   Parameters and references 134

   7.7   Recursion 135

   7.8   Putting it together 137
      Revisiting the mathq program 137, Routine examples 139

   7.9   Exercises 140

8 References and aggregate data structures 141

   8.1   Creating references 143
      Nested or multi-dimensional arrays 147, Nested hashes 149, Mixed structures 149

   8.2   Scope and references 150

   8.3   References to functions 152
      Closures 153

   8.4   Nested structures on the fly 155

   8.5   Review 158

   8.6   Exercises 159

9 Documentation 160

   9.1   User documentation and POD 161

   9.2   Source code documentation 164
      Other uses of LP 169

   9.3   Tangling code 170
      A simple tangler 170

   9.4   Further resources 178

III Practical elements

10 Regular expressions 183

   10.1   The basic components 184

   10.2   The character class 188
      Search and replace: capitalize headings 189, Character class shortcuts 191

   10.3   Greedy quantifiers: take what you can get 191

   10.4   Non-greedy quantifiers: take what you need 192

   10.5   Simple anchors 193

   10.6   Grouping, capturing, and backreferences 195
      Prime number regex 196

   10.7   Other anchors: lookahead and lookbehind 198
      Inserting commas in a number 198

   10.8   Exercises 201

11 Working with text 202

   11.1   The match operator 203
      Context of the match operator 206

   11.2   The substitution operator 207

   11.3   Strings within strings 208

   11.4   Translating characters 211

   11.5   Exercises 212

12 Working with lists 214

   12.1   Processing a list 215

   12.2   Filtering a list 217

   12.3   Sorting lists 217

   12.4   Chaining functions 221

   12.5   Reverse revisited 223

   12.6   Exercises 224

13 More I/O 225

   13.1   Running external commands 226

   13.2   Reading and writing from/to external commands 227

   13.3   Working with directories 228

   13.4   Filetest operators 229

   13.5   faqgrep revisited 230

   13.6   Exercises 233

14 Using modules 234

   14.1   Installing modules 236

   14.2   Using modules 237

   14.3   File::Basename 238

   14.4   Command line options 239

   14.5   The dating game 241

   14.6   Fetching webpages 243
      Stock quotes and graphs 243

   14.7   CGI.pm 249

   14.8   Reuse, don't reinvent 253

   14.9   Exercises 255

15 Debugging 256

   15.1   Debugging by hand 257

   15.2   The Perl debugger 262

IV Advanced elements

16 Modular programming 271

   16.1   Modules and packages 272

   16.2   Making a module 274

   16.3   Why make modules? 278

   16.4   Exercises 279

17 Algorithms and data structuring 280

   17.1   Searching 281

   17.2   Sorting 283

   17.3   Heap sort 286

   17.4   Exercises 291

18 Object-oriented programming and abstract data structures 292

   18.1   What is OOP? 293

   18.2   OOP in Perl 295
      The basics 295, Inheritance 299

   18.3   Abstract data structures 301

   18.4   Stacks, queues, and linked lists 301
      Stacks 301, Queues 307, Linked lists 309

   18.5   Exercises 314

19 More OOP examples 315

   19.1   The heap as an abstract data structure 316

   19.2   Grades: an object example 320

   19.3   Exercises 330

20 What's left? 331

appendix A     Command line switches 333

appendix B     Special variables 336

appendix C     Additional resources 338

appendix D     Numeric formats 340

glossary 342

index 348

DESCRIPTION

As the complexity of web sites grows, more and more webmasters need to acquire programming skills. Naturally, such persons are inclined to learn Perl, the "language of the web." However, there has been no book to treat Perl as the first programming language; every Perl book assumes that the reader can program already.

Until now.

Elements of Programming with Perl is a general introduction to programming, using Perl as the implementation language. It starts at the beginning, teaching programming style, structure, and design. It covers all the fundamental elements of Perl (e.g., pattern matching and text processing) and proceeds to advanced concepts, including modular programming, abstract data structures, and object oriented programming.

Elements of Programming with Perl contains numerous examples and diagrams that illustrate concepts, algorithms and techniques. Complete example programs show the new programmer how to tie concepts together to solve real-world problems.

Elements of Programming with Perl is designed for the new programmer who needs to know Perl, and for the regular Perl user who would like to improve his or her programming skills.

Translation rights for Elements of Programming with Perl have been granted for France, Germany, India and Japan. If you are interested in learning where to buy this book in a language other than English, please inquire at your local bookseller.

WHAT THE EXPERTS SAY ABOUT THIS BOOK...

"It is a very good introduction to Perl -- and programming -- for the neophyte who has never taken a programming course, or the webmaster who never learned the lessons that would be taught in one. It makes a great companion to the Llama for those who need more thorough explanations, or just like a little theory with their tools."
--Rachel Rawlings at perlmonth.com

"This book would appear to fall neatly between Learning Perl, which is targeted not only to the Perl beginner, but to the programming beginner as well, and Programming Perl, making it an ideal entry text for experienced programmers in other languages."
--Editor Arthur Corliss with Alaska Perl Mongers

"New to programming, and think Perl may be up your alley? Andrew Johnson's excellent Elements of Programming with Perl will teach you both disciplines...From the start, Johnson's explanations are clean and clear. It's obvious that he's polished his didactic style through years of real world teaching. Also from the start, good programming practices receive due emphasis...

This is a good introduction to Perl, and a very good introduction to programming in general. Johnson promotes good habits and discipline... It's a rare book that teaches as well as it informs, so take the plunge and teach yourself Perl and programming."
--chromatic, slashdot.org

"It seems quite clear that Elements of Programming with Perl is the first book that you would want to actually recommend…[which teaches Perl to non-programmers]…without worrying that they'll have to be entirely retrained afterwards. Johnson does a good job of presenting the basics. After a short introduction to both programming and Perl, the book moves immediately on to structure and style…I am quite happy to recommend this title. The book is informative and clear, and is a good introduction to basic programming and Perl."
--David Adler, Perl Mongers User Group

"Continuing to expand its very strong series of Perl books, Manning Publications has come out with Elements of Programming with Perl, a beginner's Perl text that's meant, in part, to compete with O'Reilly & Associates' Learning Perl and other standard texts of the Perl programming community. Elements of Programming with Perl communicates the basics of the language without the smarty-pants tone that the O'Reilly book slips into from time to time.

...this book provides an excellent introduction to procedural programming concepts (and the special rules of regular expressions), using Perl as a medium. It's a great book for novice and intermediate programmers."
--David Wall, The Development Exchange Enterprise Zone

WHAT THE READERS SAY ABOUT THIS BOOK...

"I learnt enough about Perl from this book to actually be productive with it, and it was enjoyable enough to encourage me to start playing with the language."
--Kelsey Gray, Perl Newbie

ABOUT THE AUTHOR...

Not only does Andrew L. Johnson hold a master's degree in anthropology, but he also has more than 15 years of experience programming in a variety of languages. As a consultant he does custom data manipulation and analysis programming for market research. He has written training materials, articles for scientific journals, and articles and reviews for the Linux Journal. He has been a regular contributor to the comp.lang.perl.misc newsgroup.

Home | Catalog | Privacy Policy | About Manning

© 2003-2006 Manning Publications Co.