Perl One-Liners Guide
About
When it comes to command line text processing, there are several well known tools like grep for filtering, sed for substitution and awk for field processing. Compared to such tools, Perl has a feature rich regular expression engine, plenty of builtin modules and a thriving ecosystem. Another advantage is that Perl is more portable.
Perl One-Liners Guide will show examples for filtering and substitution features, field processing, using standard and third-party modules, multiple file processing, how to construct solutions that depend on multiple records, how to compare records and fields between two or more files, how to identify duplicates while maintaining input order and so on.
This book heavily leans on examples to present features one by one. Exercises are also included to test your understanding.
Promo video
Prerequisites
You should be comfortable with programming basics and have prior experience working with Perl. You should know concepts like scalar, array, hash, special variables and be familiar with control structures, regular expressions, etc.
You should be familiar with command line usage in a Unix-like environment. You should also be comfortable with concepts like file redirection and command pipelines. Knowing the basics of the grep
, sed
and awk
commands will come in handy as well.
You are also expected to get comfortable with reading manuals, searching online, visiting external links provided for further reading, tinkering with illustrated examples, asking for help when you are stuck and so on. In other words, be proactive and curious instead of just consuming the content passively.
Testimonials
This is fantastic! 👏 I use Perl one-liners for record and text processing a lot and this will be definitely something I will keep coming back to - I’ve already learned a trick from “Context Matching” (9) 🙂 — feedback on Linux@lemmy.ml
Sample chapters
For a preview of the book, see sample chapters on GitHub.
GitHub repo
Visit https://github.com/learnbyexample/learn_perl_oneliners for markdown source, example files, exercise solutions and other details related to the book.
Chapters
- Preface
- One-liner introduction
- Line processing
- In-place file editing
- Field separators
- Record separators
- Using modules
- Multiple file input
- Processing multiple records
- Two file processing
- Dealing with duplicates
- Perl rename command
Feedback and Errata
I would highly appreciate it if you'd let me know how you felt about this ebook. It could be anything from a simple thank you, Gumroad rating, pointing out a typo, mistakes in code snippets, which aspects of the book worked for you (or didn't!) and so on. Reader feedback is essential and especially so for self-published authors.
You can reach me via:
- Issue Manager:Â https://github.com/learnbyexample/learn_perl_oneliners/issues
- E-mail: learnbyexample.net@gmail.com
- Twitter: https://twitter.com/learn_byexample
You'll get PDF and EPUB versions of the book.