Beginning Perl |
Page 2 of 2
Author: Curtis “Ovid” Poe Chapters 4 to 8 examine the fundamental building blocks of the language, namely functions, references, subroutines,control flow and regular expressions, yes, they are considered a core component of the language. Ovid covers the modern style of Perl and best practices such as using strict, warnings, diagnostics or even: ".....don’t use camelCaseWords. Instead, we use words_separated_by_underscores. This is because the latter is easier to read, particularly for those who do not speak English as a first language". However, it does not forego mentioning the "old-school" style, for example when opening a file: "The first syntax above is referred to as the “three argument open” and the second is the “two argument open”. The second is an older version of open() and it’s generally frowned upon today, but we’ll explain it just a bit so you can understand it if you see it in legacy code (if someone is still writing using the two argument open today, it’s either because they must support a version of Perl prior to version 5.6 or they don’t know any better)" so it provides a complete perspective of the language. Of course, whenever applicable, the user is warned about potential gotchas arising from Perl's loose but flexible rules: "Note that we have parentheses around the variables we’re assigning the subroutine arguments to. This is just normal Perl syntax for force list context. Here’s a common mistake many Perl beginners make:
That evaluates the @_ array in scalar context, setting $number_of_sides to the number of elements in @_. That’s probably not what you wanted." Theory is put into practice through useful code examples, and additionally at the end of each chapter, there is a set of exercises for the reader to complete. The exercises start easy but gradually build up to the point of developing a full fledged web application for fighting DMCA takedown notices! Chapter 9 covers file handling and general I/O while Chapter 10 covers the sort, map and grep operators. These operators are treated with awe, which probably arises from that they are considered responsible for a large part of Perl's idiomatic behavior, TMTOWTDI, flexibility and mix and match ability. Beware, anyone who masters their dark powers, like the Schwartzian Transform,is accused of Wizardry…. Chapters 11 covers Packages and Modules, prerequisites for jumping into the Object Oriented Programming chapters: Chapter 12: Object Oriented Perl and Chapter 13:Moose. It again begins with the basics, i.e what an object is, and looks at OOP from Perl's minimal perspective, which will surprise you if you are used to the classic OO paradigm from other static languages like Java or C# . If that is the case, then the Moose chapter will look more familiar and easier to follow. On the other side, if you are a newbie then it might serve as a good starting point to the object world. Anyway, Moose is the recommended way of doing OO in Perl nowadays, but you cannot escape the past... The next chapters contain the material you should be focusing to for propelling your career, mainly Testing in Chapter 14, Interwebs (Chapter 15) and Databases (Chapter 16). The Interwebs chapter starts off at an elementary level with what the HTTP protocol is and gradually progresses into building a web site by means of Plack. It is a thorough example comprising HTTP requests, cookies, parameters, sessions and anything else needed. The same goes for the Databases chapter, which starts with what a database is and again gradually progresses into using DBI and working with SQLite. Catalyst,DBI:Class ORM and Template::Toolkit are covered in the last chapter, Chapter 19: The Next Steps. Chapter 17: Plays Well With Others mostly talks about the command line, reading input or writing/piping to and from other programs, while Chapter 18 is about completing common tasks frequently encountered in the workplace such as working with CSV Data, reading and writing XML or parsing and manipulating dates.
In the end I think that the author delivers what he set out to do. The book is written in non-intimidating language, free of techno-babble, and smoothly advances the beginner from writing 'scripts' to OOP and Web frameworks. Ovid infuses the material with his confidence, leaving the reader with the "that guy knows what he is talking about" impression. This becomes even more noteworthy, when you consider that those who excel technically are not necessarily the best at communicating their expertise to the reader. Lastly, I want to emphasize the value of Ovid's advice, diffused all over the book, drawn on more than a decade of field experience. Heck, I'd get the book based just on that alone. Related ArticlesIn Praise of Perl and the Llama
|
||||||
Last Updated ( Thursday, 02 May 2013 ) |