Learning the perls
20 November 2012
After some time muddling through with Perl, I have accepted the inevitable – it's time to actually knuckle down and learn it properly. I have acquired some books, but I also require some direction – so I asked my excellent colleague and friend Mark Norman Francis to write a brief guest post for my blog.
His instructions were "Complete the sentence: In order to understand C you need to understand Pointer Arithmetic. In order to understand Perl you need to understand...". He went many better, and produced the following:
In order to write perl in a modern context, I think these are the basic skills you'll need.
- Perl's provided documentation is extensive and worthwhile, so learn to use `perldoc` to read both the provided manuals and the documentation of the builtin perl functions.
- Learn the difference between variables – scalar, array, hash, and references (hint for references: learn to make a hash of hashes).
- Learn how to use an array as a stack.
- Basic regular expression usage – matching, replacing, capturing substrings, case-insensitivity, metacharacters, and writing more readable expressions by having perl ignore the whitespace.
- Learn to use perl on the command line as a pipe filter instead of awk/sed.
- Learn how to write your own functions.
- Learn how to use core modules such as `File::Find` (write a tool to list files in a directory structure from smallest to largest in size).
- Refactor the code from step 7 to use a Schwartzian Transform to sort the file sizes.
- Learn how to install third-party libraries from CPAN.
- Install Moose from CPAN, then work through `Moose::Manual` and `Moose::Cookbook` to learn to write modern OO perl.
- Learn how to use `Test::More` to test code and `Devel::Cover` to produce coverage reports.
- Find an abstract intro to OO example (such as employee payroll) and write it in Moose with full unit test coverage.
- Lastly, read the `perlstyle` documentation, and then write your own style guide.
Thanks, Norm. Thorm.
If you’d like to be notified when I publish a new post, and possibly receive occasional announcements, sign up to my mailing list: