8 of 10 people found the following review helpful
Interesting (if flawed) guide to an under-used Perl feature,
This review is from: Perl One-Liners: 130 Programs That Get Things Done (Kindle Edition)
Perl one-liners are an important part of its power and flexibility. The ability to process a file quickly without having to write a program is often really useful. Any Perl programmers should take the time to get to know the command like switches that make this possible. This book is a pretty good introduction to this way of using Perl.
So why only three stars? Well, I have a couple of reservations about the book. Firstly, there are a few technical errors which the editors should have caught. For example, a few times the author refers to "array context" where he means "list context". The difference between arrays and lists is often difficult for beginners to master and it doesn't help when books blur the distinction.
My other reservation is with the programs themselves. The book boasts "130 programs that get things done". But I think they have had to stretch things a bit to get to that number. One program might be "print lines that match a pattern". Then the next program will be "print lines that don't match a pattern". I'm not sure that inverting the logic in a one-liner is enough of a difference to justify counting it separately. Sometimes you'll come across two or three pages of examples all of which are only tiny permutations of each other.
But it's good to see publishers bringing out books on Perl. And this is certainly an area of Perl that hasn't received much coverage before. I just think it's a rather thin concept to spin out to a book. Even this stretched, it's a rather thin book (140 pages - 50 of which are appendices). It might have been better as a cheap Kindle-only publication.
Tracked by 2 customers
Sort: Oldest first | Newest first
Showing 1-3 of 3 posts in this discussion
Initial post: Dec 20, 2013 4:12:50 AM PST
Peteris Krumins says:
Thanks for the review David!
My apologies for writing "array context" on page 40 in the book. I scanned through the book and it was the only place I had mistakenly written so. It should say "list context" there like this:
"In the _list context_, both gmtime and localtime return a nine-element list"
I just let my publisher know and the Kindle and ebook versions will have this inaccuracy fixed, and this update will be posted on the book's website at nostarch.com/perloneliners.
David, it would be great if you could let me know other inaccuracies that you found (email me email@example.com).
If any of the book readers have trouble understanding arrays and lists (or anything else) email me firstname.lastname@example.org at any time and I'll help you understand the difference!
I personally love the style of making small incremental changes to show how you can easily change one-liners to do more or less things. I also like showing the readers how to do the same thing in many different ways following the "there's more than one way to do it" Perl's mantra. I also enjoy showing the readers how to golf Perl programs (writing a very short version of the same program). That's why I sometimes spend a page or two writing examples which are tiny permutations of each other.
There's a really interesting reason why some of the programs are just the inverse of the other like you mentioned. If you google "awk1line.txt" and "sed1line.txt", you'll find two very interesting files full of awk and sed one liners, which I found very entertaining to work through when I was learning awk and sed. I followed the structure of this file closely when I wrote Perl one liners (and "perl1line.txt" file). That is why some programs are just inverses of each other!
I haven't really counted how many programs total there are in the book, but probably well over 200. There are 130 one-liners in the table of contents, but that doesn't include many different one-liners that appear in introduction, appendix A, and the many permutations and golfed examples.
Posted on Mar 20, 2014 12:03:03 AM PDT
Nice review. My question about the book, which I'm assuming you answered in the affirmative is - is the whole book PERL command line "programs?"
I got to here looking for the book "Perl Phrasebook" which I thought might have some good useful example codes in PERL, but that book appears to be out of print, and also not on Kindle.
I've used PERL quite a lot, but for some reason I just cannot become fluent or comfortable with it and I am looking for a book to give me a repertoire of useful chunks PERL I can remember.
In reply to an earlier post on Mar 20, 2014 12:11:13 AM PDT
David Cross says:
Bruce, yes, this book is all command line programs.
For what you want, you could take a look at "Effective Perl Programming". I'd recommend "The Perl Cookbook", but the Perl it uses looks a little dated now.
Oh, and it's "Perl", not "PERL" :-)
‹ Previous 1 Next ›