Perl Hacks By chromatic , Damian Conway, Curtis "Ovid" Poe ............................................... Publisher: O'Reilly Pub Date: May 2006 Print ISBN-10: 0-596-52674-1 Print ISBN-13: 978-0-59-652674-0 Pages: 296 Table of Contents | Index With more than a million dedicated programmers, Perl has proven to be the best computing language for the latest trends in computing and business. While other languages have stagnated, Perl remains fresh thanks to its community-based development model, which encourages the sharing of information among users. This tradition of knowledge-sharing allows developers to find answers to almost any Perl question they can dream up. And you can find many of those answers right here in Perl Hacks. Like all books in O'Reilly's "Hacks" series, Perl Hacks appeals to a variety of programmers, whether you're a experienced developer or a dabbler who simply enjoys exploring technology. Each hack is a short lesson - some are practical exercises that teach you essential skills, while others merely illustrate some of the fun things that Perl can do. Most hacks have two parts: a direct answer to the immediate problem you need to solve right now and a deeper, subtler technique that you can adapt to other situations. Learn how to add CPAN shortcuts to the Firefox web browser, read files backwards, write graphical games in Perl, and much more. For your convenience, Perl Hacks is divided by topic - not according to any sense of relative difficulty - so you can skip around and stop at any hack you like. Chapters include: Productivity Hacks User Interaction Data Munging Working with Modules Object Hacks Debugging Whether you're a newcomer or an expert, you'll find great value in Perl Hacks, the only Perl guide that offers something useful and fun for everyone. Perl Hacks By chromatic , Damian Conway, Curtis "Ovid" Poe ............................................... Publisher: O'Reilly Pub Date: May 2006 Print ISBN-10: 0-596-52674-1 Print ISBN-13: 978-0-59-652674-0 Pages: 296 Table of Contents | Index Copyright credits Credits Preface Chapter 1. Productivity Hacks Hack 1. Add CPAN Shortcuts to Firefox Hack 2. Put Perldoc to Work Hack 3. Browse Perl Docs Online Hack 4. Make the Most of Shell Aliases Hack 5. Autocomplete Perl Identifiers in Vim Hack 6. Use the Best Emacs Mode for Perl Hack 7. Enforce Local Style Hack 8. Don't Save Bad Perl Hack 9. Automate Checkin Code Reviews Hack 10. Run Tests from Within Vim Hack 11. Run Perl from Emacs Chapter 2. User Interaction Hack 12. Use $EDITOR As Your UI Hack 13. Interact Correctly on the Command Line Hack 14. Simplify Your Terminal Interactions Hack 15. Alert Your Mac Hack 16. Interactive Graphical Apps Hack 17. Collect Configuration Information Hack 18. Rewrite the Web Chapter 3. Data Munging Hack 19. Treat a File As an Array Hack 20. Read Files Backwards Hack 21. Use Any Spreadsheet As a Data Source Hack 22. Factor Out Database Code Hack 23. Build a SQL Library Hack 24. Query Databases Dynamically Without SQL Hack 25. Bind Database Columns Hack 26. Iterate and Generate Expensive Data Hack 27. Pull Multiple Values from an Iterator Chapter 4. Working with Modules Hack 28. Shorten Long Class Names Hack 29. Manage Module Paths Hack 30. Reload Modified Modules Hack 31. Create Personal Module Bundles Hack 32. Manage Module Installations Hack 33. Presolve Module Paths Hack 34. Create a Standard Module Toolkit Hack 35. Write Demos from Tutorials Hack 36. Replace Bad Code from the Outside Hack 37. Drink to the CPAN Hack 38. Improve Exceptional Conditions Hack 39. Search CPAN Modules Locally Hack 40. Package Standalone Perl Applications Hack 41. Create Your Own Lexical Warnings Hack 42. Find and Report Module Bugs Chapter 5. Object Hacks Hack 43. Turn Your Objects Inside Out Hack 44. Serialize Objects (Mostly) for Free Hack 45. Add Information with Attributes Hack 46. Make Methods Really Private Hack 47. Autodeclare Method Arguments Hack 48. Control Access to Remote Objects Hack 49. Make Your Objects Truly Polymorphic Hack 50. Autogenerate Your Accessors Chapter 6. Debugging Hack 51. Find Compilation Errors Fast Hack 52. Make Invisible Characters Apparent Hack 53. Debug with Test Cases Hack 54. Debug with Comments Hack 55. Show Source Code on Errors Hack 56. Deparse Anonymous Functions Hack 57. Name Your Anonymous Subroutines Hack 58. Find a Subroutine's Source Hack 59. Customize the Debugger Chapter 7. Developer Tricks Hack 60. Rebuild Your Distributions Hack 61. Test with Specifications Hack 62. Segregate Developer and User Tests Hack 63. Run Tests Automatically Hack 64. See Test Failure Diagnostics in Color! Hack 65. Test Live Code Hack 66. Cheat on Benchmarks Hack 67. Build Your Own Perl Hack 68. Run Test Suites Persistently Hack 69. Simulate Hostile Environments in Your Tests Chapter 8. Know Thy Code Hack 70. Understand What Happens When Hack 71. Inspect Your Data Structures Hack 72. Find Functions Safely Hack 73. Know What's Core and When Hack 74. Trace All Used Modules Hack 75. Find All Symbols in a Package Hack 76. Peek Inside Closures Hack 77. Find All Global Variables Hack 78. Introspect Your Subroutines Hack 79. Find Imported Functions Hack 80. Profile Your Program Size Hack 81. Reuse Perl Processes Hack 82. Trace Your Ops Hack 83. Write Your Own Warnings Chapter 9. Expand Your Perl Foo Hack 84. Double Your Data with Dualvars Hack 85. Replace Soft References with Real Ones Hack 86. Optimize Away the Annoying Stuff Hack 87. Lock Down Your Hashes Hack 88. Clean Up at the End of a Scope Hack 89. Invoke Functions in Odd Ways Hack 90. Glob Those Sequences Hack 91. Write Less Error-Checking Code Hack 92. Return Smarter Values Hack 93. Return Active Values Hack 94. Add Your Own Perl Syntax Hack 95. Modify Semantics with a Source Filter Hack 96. Use Shared Libraries Without XS Hack 97. Run Two Services on a Single TCP Port Hack 98. Improve Your Dispatch Tables Hack 99. Track Your Approximations Hack 100. Overload Your Operators Hack 101. Learn from Obfuscations Colophon Index Copyright © 2006 O'Reilly Media, Inc. All rights reserved. Printed in the United States of America. Published by O'Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O'Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://safari.oreilly.com). For more information, contact our corporate/institutional sales department: (800) 998-9938 or [email protected]. Nutshell Handbook, the Nutshell Handbook logo, and the O'Reilly logo are registered trademarks of O'Reilly Media, Inc. The Hacks series designations, Perl Hacks, the image of a pair of work boots, and related trade dress are trademarks of O'Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O'Reilly Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. Small print: The technologies discussed in this publication, the limitations on these technologies that technology and content owners seek to impose, and the laws actually limiting the use of these technologies are constantly changing. Thus, some of the hacks described in this publication may not work, may cause unintended harm to systems on which they are used, or may not be consistent with applicable user agreements. Your use of these hacks is at your own risk, and O'Reilly Media, Inc. disclaims responsibility for any damage or expense resulting from their use. In any event, you should take care that your use of these hacks does not violate any applicable laws, including copyright laws. Credits About the Authors chromatic works for O'Reilly Media, where he edits the free and open source web sites of the O'Reilly Network. In his spare time, he writes books such as this one. In the remaining minutes, he contributes to the CPAN, Perl 5, Perl 6, Parrot, and even Pugs. He lives just west of Portland, Oregon by a park and a creek and would like to finish more projects someday, including writing a novel, a comic book, a television show, and sleeping. Catch up on his hobbies at http://wgz.org/chromatic. Dr. Damian Conway is a professional Perl boffin. As the author of numerous popular CPAN modules (http://search.cpan.org/~dconway) and two highly regarded books on Perl, he is also a widely sought-after conference speaker and runs an international IT training companyThoughtstream (http://damian.conway.org)which provides Perl training from beginner to masterclass level throughout Europe, North America, and Australasia. He spends most of his less-than-copious free time working with Larry Wall on the design of Perl 6. [Hack #5], [Hack #13], [Hack #14], [Hack #34], [Hack #54], [Hack #86], [Hack #90], [Hack #92], [Hack #93], [Hack #94], [Hack #95], [Hack #99], [Hack #100] Earlier this century, displaying his usual stellar sense of timing, Curtis "Ovid" Poe switched from mainframes to web programming in Perl and promptly watched the dot-com industry implode. Despite this minor setback and working for several currently non-existent companies, Ovid stuck with Perl and actually discovered he liked it. A frequent speaker at user groups and author of numerous CPAN modules and a popular Perl CGI course, Ovid is a Perl Foundation Steering Committee member and also heads the TPF grant committee.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages357 Page
-
File Size-