This book focuses on Perl usage from the command line, similar to
awk usage. Syntax and features of these tools (along with languages like
bash) were inspirations for Perl, so prior experience with them would make it easier to learn Perl.
You'll learn about various command line options and Perl features that make it possible to write compact cli scripts. Learning to use Perl from the command line will also allow you to construct solutions where Perl is just another tool in the shell ecosystem.
You should be comfortable with programming basics and have prior experience working with Perl. You should know concepts like scalar, array, hash and special variables, be familiar with control structures, regular expressions etc. If you need resources to get started with Perl and regular expressions, you can start with these links:
You should also have prior experience working with command line,
bash shell and be familiar with concepts like file redirection, command pipeline and so on.
- The examples presented here have been tested with Perl version 5.32.0 and includes features not available in earlier versions.
- Code snippets shown are copy pasted from bash shell and modified for presentation purposes. Some commands are preceded by comments to provide context and explanations. Blank lines have been added to improve readability, only
realtime is shown for speed comparisons and so on.
- Unless otherwise noted, all examples and explanations are meant for ASCII characters
- External links are provided for further reading throughout the book. Not necessary to immediately visit them. They have been chosen with care and would help, especially during re-reads.
- The learn_perl_oneliners repo has all the code snippets and files used in examples and exercises and other details related to the book. If you are not familiar with
gitcommand, click the Code button on the webpage to get the files.
- perl documentation — manuals, tutorials and examples
- /r/perl/ — helpful forum for beginners and experienced programmers alike
- stackoverflow — for getting answers to pertinent questions on Perl, one-liners, etc
- tex.stackexchange — for help on
- LibreOffice Draw — cover image
- pngquant and svgcleaner for optimizing images
- Warning and Info icons by Amada44 under public domain
- softwareengineering.stackexchange and skolakoda for programming quotes
- mdBook — for web version of the book that you are currently reading
A heartfelt thanks to all my readers. Your valuable support has significantly eased my financial concerns and allows me to continue writing books.
I would highly appreciate if you'd let me know how you felt about this book, it would help to improve this book as well as my future attempts. Also, please do let me know if you spot any error or typo.
Sundeep Agarwal is a freelance trainer, author and mentor. His previous experience includes working as a Design Engineer at Analog Devices for more than 5 years. You can find his other works, primarily focused on Linux command line, text processing, scripting languages and curated lists, at https://github.com/learnbyexample. He has also been a technical reviewer for Command Line Fundamentals book and video course published by Packt.
List of books: https://learnbyexample.github.io/books/
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License
Code snippets are available under MIT License
Resources mentioned in Acknowledgements section above are available under original licenses.
See Version_changes.md to track changes across book versions.