Part of the fun of programming in Perl lies in tackling tedious tasks with short, efficient, and reusable code. Often, the perfect tool is the one-liner, a small but powerful program that fits in one line of code and does one thing really well.
InPerl One-Liners, author and impatient hacker Peteris Krumins takes you through more than 100 compelling one-liners that do all sorts of handy things, such as manipulate line spacing, tally column values in a table, and get a list of users on a system. This cookbook of useful, customizable, and fun scripts will even help hone your Perl coding skills, as Krumins dissects the code to give you a deeper understanding of the language.
You'll find one-liners that:
- Encode, decode, and convert strings
- Generate random passwords
- Calculate sums, factorials, and the mathematical constants π ande
- Add or remove spaces
- Number lines in a file
- Print lines that match a specific pattern
- Check to see if a number is prime with a regular expression
- Convert IP address to decimal form
- Replace one string with another
And many more! Save time and sharpen you coding skills as you learn to conquer those pesky tasks in a few precisely placed keystrokes with
Perl One-Liners.
Peteris Krumins is a programmer, systems administrator, start-up manager, and all-around hacker. He is the cofounder of Browserling and Testling, and he runs the popular programming blog catonmat.net.
About the Author;About the Technical Reviewer;Acknowledgments;Chapter 1: Introduction to Perl One-Liners;Chapter 2: Spacing;2.1 2.1 Double-space a file;2.2 2.2 Double-space a file, excluding the blank lines;2.3 2.3 Triple-space a file;2.4 2.4 N-space a file;2.5 2.5 Add a blank line before every line;2.6 2.6 Remove all blank lines;2.7 2.7 Remove all consecutive blank lines, leaving only one;2.8 2.8 Compress/expand all blank linl³—