Perl Best Practices

Perl Best Practices by Damian Conway

Perl Best Practices

Binding:
Paperback
Number of Pages:
544
ISBN:
0596001738
Product Group:
book
Publisher:
O'Reilly Media
Publication Date:
July 12, 2005
BooksForGeeks.com ID:
1358

Offering a collection of 256 guidelines on the art of coding to help you write better Perl code, this book covers code layout, naming conventions, choice of data and control structures, program decomposition, interface design and implementation, modularity, object orientation, error handling, testing, and debugging.

Reviews for Perl Best Practices

  1. Detoxing Perl - A must for anyone who writes longer Perl scripts

    Rated 5 out of 5 stars, May 12th, 2008

    The Perl motto "there's more than one way to do it" comes to bite you as you start to write longer and longer codes. Other people's Perl "codes" are often totally intractable and my scripts were probably even worse... Where does it all go wrong? Most of us who "code" in Perl started off writing short scripts to do simple tasks and it just grew - still looking like scripts but longer, meaner and weirder.

    The Best Practices starts off with formatting. Seemingly trivial but it really makes a big difference to the legibility of your code. I've taken away the formatting guide to when coding in Matlab too. Small things like spacing makes a big difference:

    $average = ($one + $two + three) / 3;

    is better than

    $average=( $one+$two+$three )/3;

    Perl Best Practices consists of a series of do's and don'ts. For example, don't use postfix looping controls like "do {...} while ($ii < 10)". Use "for my $ii (0..10) {...}". Did you also know that for and foreach loop declare their own local loop variable within the for loop? So $ii outside the loop is not the same as inside the loop in the following code:

    my $ii = -1;
    LOOP:
    for $ii (0..10) {
    last LOOP if ($ii >= 5);
    }
    print "$ii\n"; # This prints -1 not 5!

    Some of the Best Practices are quite severe but there are lots of useful bits that you can pick and mix. All the best practices are clearly illustrated with don'ts followed by do's (in bold). Those with previous programming experience might even be better off starting with this book (supplemented with some online materials) to avoid picking up bad habits.

    This book will make your Perl scripts more readable, more efficient, easier to debug and maintain.
  2. No Perl bookshelf should be without it...

    Rated 5 out of 5 stars, July 12th, 2007

    I have to agree with the previous reviewers that this book will seriously change the way you code Perl. Having read this you will write more readable, more maintainable, more thoughtful, better documented (and better self-documenting) code... and this in addition to learning techniques to simply writing *better* code.

    Use the downloadable files to amend your Emacs/Vim config to the PBP way, and run all your pre-release code through perltidy and Perl::Critic (using the PBP theme) and you will wonder why you ever released those un-readable, "I'm pretty sure I understood what I was doing when I wrote this", scripts/modules in the past.

    Yet another classic from the O'Reilly stables.
  3. Best Perl book ever

    Rated 5 out of 5 stars, July 12th, 2007

    Not only the best Perl book I've ever read, it's also one of the best programming language books, period.

    If you've ever programmed C++ or Java, you'll know how revered the likes of Effective C++ and Effective Java are, a series of tips, suggestions, idioms, advice and commandments. This is the equivalent for Perl, except it's even more thorough and covers even more ground, from brace layout and statement formatting, to regexes, unit testing, documentation and command line parsing.

    There's also an exceptionally good chapter on object orientation, wherein author Damian Conway guides the reader through the use of his own Class::Std module. If you're using objects in Perl, and you're still rolling your own, you're really making life unnecessarily difficult for yourself. Class::Std provides object features reminiscent of CLOS, and makes Perl competitive with the likes of Python and Ruby when it comes to objects. Class::Std has changed the way I code Perl forever, and I know I'm not the only one. Seriously, this chapter is worth the price of admission on it own.

    It's hard to overstate just how much excellent stuff there is in here, there's even useful emacs and vi settings provided! And I've not even mentioned how well written it is. Damian Conway really does prove himself the master of witty examples.

    Perl Best Practices is just brilliant. Absolutely essential reading - don't code Perl without it.
  4. Wow

    Rated 5 out of 5 stars, December 12th, 2005

    I have been programming computers for the last 22 years. I loved Perl from the moment I set eyes on it. After I receiving my copy of Damian Conway's new book I love Perl even more.

Our Network

BooksForGeeks.com is a participant in the Amazon Europe S.à r.l. Associates Programme, an affiliate advertising programme designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.co.uk