Synopses & Reviews
This is the third in O'Reilly's series of landmark Perl tutorials, which started with Learning Perl, the bestselling introduction that taught you the basics of Perl syntax, and Intermediate Perl, which taught you how to create re-usable Perl software. Mastering Perl pulls everything together to show you how to bend Perl to your will. It convey's Perl's special models and programming idioms.
This book isn't a collection of clever tricks, but a way of thinking about Perl programming so you can integrate the real-life problems of debugging, maintenance, configuration, and other tasks you encounter as a working programmer.
The book explains how to:
- Use advanced regular expressions, including global matches, lookarounds, readable regexes, and regex debugging
- Avoid common programing problems with secure programming techniques
- Profile and benchmark Perl to find out where to focus your improvements
- Wrangle Perl code to make it more presentable and readable
- See how Perl keeps track of package variables and how you can use that for some powerful tricks
- Define subroutines on the fly and turn the tables on normal procedural programming.
- Modify and jury rig modules to fix code without editing the original source
- Let your users configure your programs without touching the code
- Learn how you can detect errors Perl doesn't report, and how to tell users about them
- Let your Perl program talk back to you by using Log4perl
- Store data for later use in another program, a later run of the same program, or to send them over a network
- Write programs as modules to get the benefit of Perl's distribution and testing tools
Appendices include "brian's Guide to Solving Any Perl Problem" to improve your troubleshooting skills, as well as suggested reading to continue your Perl education. Mastering Perl
starts you on your path to becoming the person with the answers, and, failing that, the person who knows how to find the answers or discover the problem.
Demonstrating how advanced Perl concepts make coding easier, maintenance simpler, and execution faster, "Mastering Perl" is the fourth in a series of landmark Perl tutorials.
About the Author
brian d foy has been an instructor for Stonehenge Consulting Services since 1998, a Perl user since he was a physics graduate student, and a die-hard Mac user since he first owned a computer. He founded the first Perl user group, the New York Perl Mongers, as well as the Perl advocacy nonprofit Perl Mongers, Inc., which helped form more than 200 Perl user groups across the globe. He maintains the perlfaq portions of the core Perl documentation, several modules on CPAN, and some stand-alone scripts. He's the publisher of The Perl Review, a magazine devoted to Perl, and is a frequent speaker at conferences including the Perl Conference, Perl University, MarcusEvans BioInformatics '02, and YAPC. His writings on Perl appear in The O'Reilly Network, The Perl Journal, Dr. Dobbs, and The Perl Review, on use.perl.org, and in several Perl usenet groups.
Table of Contents
Foreword; Preface; Structure of This Book; Conventions Used in This Book; Using Code Examples; Safari® Enabled; Comments and Questions; Acknowledgments; Chapter 1: Introduction: Becoming a Master; 1.1 What It Means to Be a Master; 1.2 Who Should Read This Book; 1.3 How to Read This Book; 1.4 What Should You Know Already?; 1.5 What I Cover; 1.6 What I Don't Cover; Chapter 2: Advanced Regular Expressions; 2.1 References to Regular Expressions; 2.2 Noncapturing Grouping, (?:PATTERN); 2.3 Readable Regexes, /x and (?#...); 2.4 Global Matching; 2.5 Lookarounds; 2.6 Deciphering Regular Expressions; 2.7 Final Thoughts; 2.8 Summary; 2.9 Further Reading; Chapter 3: Secure Programming Techniques; 3.1 Bad Data Can Ruin Your Day; 3.2 Taint Checking; 3.3 Untainting Data; 3.4 List Forms of system and exec; 3.5 Summary; 3.6 Further Reading; Chapter 4: Debugging Perl; 4.1 Before You Waste Too Much Time; 4.2 The Best Debugger in the World; 4.3 perl5db.pl; 4.4 Alternative Debuggers; 4.5 Other Debuggers; 4.6 Summary; 4.7 Further Reading; Chapter 5: Profiling Perl; 5.1 Finding the Culprit; 5.2 The General Approach; 5.3 Profiling DBI; 5.4 Devel::DProf; 5.5 Writing My Own Profiler; 5.6 Profiling Test Suites; 5.7 Summary; 5.8 Further Reading; Chapter 6: Benchmarking Perl; 6.1 Benchmarking Theory; 6.2 Benchmarking Time; 6.3 Comparing Code; 6.4 Don't Turn Off Your Thinking Cap; 6.5 Memory Use; 6.6 The perlbench Tool; 6.7 Summary; 6.8 Further Reading; Chapter 7: Cleaning Up Perl; 7.1 Good Style; 7.2 perltidy; 7.3 De-Obfuscation; 7.4 Perl::Critic; 7.5 Summary; 7.6 Further Reading; Chapter 8: Symbol Tables and Typeglobs; 8.1 Package and Lexical Variables; 8.2 The Symbol Table; 8.3 Summary; 8.4 Further Reading; Chapter 9: Dynamic Subroutines; 9.1 Subroutines As Data; 9.2 Creating and Replacing Named Subroutines; 9.3 Symbolic References; 9.4 Iterating Through Subroutine Lists; 9.5 Processing Pipelines; 9.6 Method Lists; 9.7 Subroutines As Arguments; 9.8 Autoloaded Methods; 9.9 Hashes As Objects; 9.10 AutoSplit; 9.11 Summary; 9.12 Further Reading; Chapter 10: Modifying and Jury-Rigging Modules; 10.1 Choosing the Right Solution; 10.2 Replacing Module Parts; 10.3 Subclassing; 10.4 Wrapping Subroutines; 10.5 Summary; 10.6 Further Reading; Chapter 11: Configuring Perl Programs; 11.1 Things Not to Do; 11.2 Better Ways; 11.3 Command-Line Switches; 11.4 Configuration Files; 11.5 Scripts with a Different Name; 11.6 Interactive and Noninteractive Programs; 11.7 perl's Config; 11.8 Summary; 11.9 Further Reading; Chapter 12: Detecting and Reporting Errors; 12.1 Perl Error Basics; 12.2 Reporting Module Errors; 12.3 Exceptions; 12.4 Summary; 12.5 Further Reading; Chapter 13: Logging; 13.1 Recording Errors and Other Information; 13.2 Log4perl; 13.3 Summary; 13.4 Further Reading; Chapter 14: Data Persistence; 14.1 Flat Files; 14.2 Storable; 14.3 DBM Files; 14.4 Summary; 14.5 Further Reading; Chapter 15: Working with Pod; 15.1 The Pod Format; 15.2 Translating Pod; 15.3 Testing Pod; 15.4 Summary; 15.5 Further Reading; Chapter 16: Working with Bits; 16.1 Binary Numbers; 16.2 Bit Operators; 16.3 Bit Vectors; 16.4 The vec Function; 16.5 Keeping Track of Things; 16.6 Summary; 16.7 Further Reading; Chapter 17: The Magic of Tied Variables; 17.1 They Look Like Normal Variables; 17.2 At the User Level; 17.3 Behind the Curtain; 17.4 Scalars; 17.5 Arrays; 17.6 Hashes; 17.7 Filehandles; 17.8 Summary; 17.9 Further Reading; Chapter 18: Modules As Programs; 18.1 The main Thing; 18.2 Backing Up; 18.3 Who's Calling?; 18.4 Testing the Program; 18.5 Distributing the Programs; 18.6 Summary; 18.7 Further Reading; Further Reading; Perl Books; Non-Perl Books; brian's Guide to Solving Any Perl Problem; My Philosophy of Problem-Solving; My Method; Colophon;