Home Page Icon
Home Page
Table of Contents for
Cover
Close
Cover
by Curtis Ovid Poe, Curtis Poe, Damian Conway, Chromatic
Perl Hacks
A Note Regarding Supplemental Files
Credits
About the Authors
About the Contributors
Acknowledgments
chromatic
Damian Conway
Curtis “Ovid” Poe
Technical Reviewers
Preface
Why Perl Hacks?
How To Use This Book
How This Book Is Organized
Conventions Used in This Book
Using Code Examples
Safari Enabled
We’d Like to Hear from You
1. Productivity Hacks
1. Add CPAN Shortcuts to Firefox
Search for a Module
Read Module Documentation
Find Module Comments
Hacking the Hack
2. Put Perldoc to Work
Find Operator Documentation
Answer a FAQ
Webify It
Find that Module!
Browse the Code
3. Browse Perl Docs Online
The Hack
Running the Hack
Hacking the Hack
4. Make the Most of Shell Aliases
Configuring Your Shell
Useful Shell Aliases
Juggle multiple Perl versions
Juggle multiple module versions
Don’t forget multipart commands
Remember configuration options
Find a module’s version
Change Unix paths to Windows paths and back
5. Autocomplete Perl Identifiers in Vim
The Hack
Finding Identifiers Automatically
Hacking the Hack
6. Use the Best Emacs Mode for Perl
The Hack
Put Perldoc at your fingertips
Use a special mode just for Pod
7. Enforce Local Style
The Hack
From the command line
Within Vim
Within Emacs
8. Don’t Save Bad Perl
The Hack
Running the Hack
Hacking the Hack
9. Automate Checkin Code Reviews
The Hack
Hacking the Hack
10. Run Tests from Within Vim
The Hack
Binding keys
Seeing failures
Managing paths
11. Run Perl from Emacs
The Hack
2. User Interaction
12. Use $EDITOR As Your UI
The Hack
Running the Hack
Hacking the Hack
13. Interact Correctly on the Command Line
The Hack
The Hack
14. Simplify Your Terminal Interactions
Train -req
Yea or Nay
At the Touch of a Button
Engage Cloaking Device
What’s On the Menu?
15. Alert Your Mac
The Hack
Running the Hack
Hacking the Hack
16. Interactive Graphical Apps
Blitting with SDL Perl
Animating with SDL Perl
A Working Animation
17. Collect Configuration Information
The Hack
Using the Hack
18. Rewrite the Web
The Hack
Running the Hack
Hacking the Hack
3. Data Munging
19. Treat a File As an Array
The Hack
Running the Hack
20. Read Files Backwards
The Hack
Running the Hack
Hacking the Hack
21. Use Any Spreadsheet As a Data Source
Accessing Cell Data
Do I need Spreadsheet::Read for that?
Accessing a data column
Accessing a row of data
Using programmer-style indexing
Showing all data in a spreadsheet
How It Works
Hacking the Hack
22. Factor Out Database Code
The Hack
Running the Hack
Hacking the Hack
23. Build a SQL Library
The Hack
Running the Hack
Hacking the Hack
24. Query Databases Dynamically Without SQL
The Hack
Hacking the Hack
25. Bind Database Columns
The Hack
Running the Hack
26. Iterate and Generate Expensive Data
The Hack
Running the Hack
Hacking the Hack
27. Pull Multiple Values from an Iterator
Better Context than wantarray( )
The Code
Hacking the Hack
4. Working with Modules
28. Shorten Long Class Names
The Hack
Resolve conflicts
Importing with aliased
29. Manage Module Paths
Within Your Program
From the Command Line
With an Environment Variable
When Recompiling Perl
30. Reload Modified Modules
The Hack
Running the Hack
Hacking the Hack
31. Create Personal Module Bundles
The Hack
Running the Hack
Hacking the Hack
32. Manage Module Installations
The Hack
Running the Hack
Hacking the Hack
33. Presolve Module Paths
The Hack
Running the Hack
Hacking the Hack
34. Create a Standard Module Toolkit
A Mess of Modules
The Hack
Hacking the Hack
35. Write Demos from Tutorials
The Hack
Running the Hack
Inside the Hack
Hacking the Hack
36. Replace Bad Code from the Outside
The Hack
Hacking the Hack
37. Drink to the CPAN
Running the Hack
Hacking the Hack
38. Improve Exceptional Conditions
The Hack
Running the Hack
Hacking the Hack
39. Search CPAN Modules Locally
The Hack
Hacking the Hack
40. Package Standalone Perl Applications
The Hack
Running the Hack
Hacking the Hack
41. Create Your Own Lexical Warnings
The Hack
Running the Hack
Hacking the Hack
42. Find and Report Module Bugs
Write a Test
Submitting a bug report
Hacking the Hack
5. Object Hacks
43. Turn Your Objects Inside Out
The Hack
Running the Hack
Hacking the Hack
44. Serialize Objects (Mostly) for Free
The Hack
45. Add Information with Attributes
The Hack
Running the Hack
Hacking the Hack
46. Make Methods Really Private
The Hack
Running the Hack
Inside the hack
Hacking the Hack
47. Autodeclare Method Arguments
The Hack
Running the Hack
Hacking the Hack
48. Control Access to Remote Objects
The Hack
Hacking the Hack
49. Make Your Objects Truly Polymorphic
The Hack
Running the Hack
Hacking the Hack
50. Autogenerate Your Accessors
The Hack
Class::MethodMaker
Class::BuildMethods
Running the Hack
6. Debugging
51. Find Compilation Errors Fast
The Hack
Binary searching for bugs
Hacking the Hack
52. Make Invisible Characters Apparent
Bracket Your Variables
Bracket Interpolated Lists
Serialize Your Data
53. Debug with Test Cases
The Hack
Writing test code
From test code to test cases
Hacking the Hack
54. Debug with Comments
The Hack
Displaying variables
Making Assertions
Configuring smartness levels
55. Show Source Code on Errors
The Hack
Running the Hack
Hacking the Hack
56. Deparse Anonymous Functions
The Hack
Running the Hack
Hacking the Hack
57. Name Your Anonymous Subroutines
The Hack
Hacking the Hack
58. Find a Subroutine’s Source
The Hack
Running the Hack
59. Customize the Debugger
The Hack
Overriding a debugger command
Running the Hack
Hacking the Hack
7. Developer Tricks
60. Rebuild Your Distributions
The Hack
Running the Hack
Hacking the Hack
61. Test with Specifications
The Hack
Running the Hack
Refining your claims
Interpreting test output
Taking advantage of specification-based testing
62. Segregate Developer and User Tests
The Hack
Running the Hack
Hacking the Hack
63. Run Tests Automatically
The Hack
Running the Hack
Hacking the Hack
64. See Test Failure Diagnostics — in Color!
The Hack
Hacking the Hack
65. Test Live Code
The Hack
Hacking the Hack
66. Cheat on Benchmarks
67. Build Your Own Perl
The Hack
Running the Hack
Hacking the Hack
68. Run Test Suites Persistently
The Hack
Creating a wrapper around prove
Running the Hack
Hacking the Hack
69. Simulate Hostile Environments in Your Tests
The Hack
Simulating old versions of modules
Simulating missing modules
Running multiple scenarios
Hacking the Hack
8. Know Thy Code
70. Understand What Happens When
The Hack
Compilation
Initialization
Runtime
Cleanup
71. Inspect Your Data Structures
Dumping References Outside the Debugger
Printing to a File
Output in CGI or mod_perl Programs
72. Find Functions Safely
The Hack
Get cozy with can( )
Find functions, not methods!
73. Know What’s Core and When
The Hack
Checking by version
74. Trace All Used Modules
The Hack
Running the Hack
Hacking the Hack
75. Find All Symbols in a Package
The Hack
How does it work?
Running the Hack
76. Peek Inside Closures
The Hack
Running the Hack
Hacking the Hack
77. Find All Global Variables
The Hack
Running the Hack
Hacking the Hack
78. Introspect Your Subroutines
The Hack
Running the Hack
Hacking the Hack
79. Find Imported Functions
The Hack
Running the Hack
Hacking the Hack
80. Profile Your Program Size
The Hack
Running the Hack
Hacking the Hack
81. Reuse Perl Processes
The Hack
Running the Hack
Hacking the Hack
82. Trace Your Ops
The Hack
Running the Hack
Hacking the Hack
83. Write Your Own Warnings
The Hack
Running the Hack
Hacking the Hack
9. Expand Your Perl Foo
84. Double Your Data with Dualvars
The Hack
Running the Hack
Hacking the Hack
85. Replace Soft References with Real Ones
The Hack
Hacking the Hack
86. Optimize Away the Annoying Stuff
The Hack
Hacking the Hack
87. Lock Down Your Hashes
The Hack
Running the Hack
88. Clean Up at the End of a Scope
The Hack
Hacking the Hack
89. Invoke Functions in Odd Ways
The Hack
Make a Bareword invoke a function
Tie a scalar variable to a function
Tie an array variable to a function
Tie a hash variable to a function
Add a function-calling layer to filehandles
90. Glob Those Sequences
The Hack
Running the Hack
Hacking the Hack
91. Write Less Error-Checking Code
The Hack
Hacking the Hack
92. Return Smarter Values
Fine Distinctions
Name that Return Value
Out, Out, Damn Commas!
93. Return Active Values
The Hack
Running the Hack
Hacking the Hack
94. Add Your Own Perl Syntax
The Hack
95. Modify Semantics with a Source Filter
The Hack
Hacking the Hack
96. Use Shared Libraries Without XS
The Hack
Running the Hack
Hacking the Hack
97. Run Two Services on a Single TCP Port
The Hack
Running the Hack
Hacking the Hack
98. Improve Your Dispatch Tables
The hack
Running the Code
99. Track Your Approximations
Interval interlude
Teaching Perl to think in intervals
100. Overload Your Operators
The Hack
Saying what you mean
101. Learn from Obfuscations
Index
About the Authors
Colophon
Copyright
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Next
Next Chapter
Perl Hacks
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset