Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Perl Best Practices for Everyone!

by mikasue (Friar)
on Nov 09, 2006 at 20:09 UTC ( #583205=perlmeditation: print w/replies, xml ) Need Help??

I am reading Perl Best Practices by Damian Conway and I am finding it very helpful and encouraging.

When I began reading it, it seemed that it wasn't for perl beginners who hadn't already established a style of programming. It sounded like it was more for experienced programmers who had already adapted certain habits that they can break by reading the book. I don't already have programming habits so I felt that maybe I didn't need to read this book. However, after reading the first 3 chapters, I have found it encouraging and a very good learning tool. I felt encouraged because some of the advice described some practices that I was already doing. I have had no formal training in Perl just reading books and hanging out on Perl Monks. Felt good to know that I was doing it "right".

Perl Best Practices is also educating me on how to do some things in Perl that I don't already know how to do nor how to approach being new to the language.

I just wanted to share how my initial thoughts of this book were wrong and I believe everyone should read this book new or old to programming!

Because of the initial feeling I wonder:

How many of you seasoned programmers have changed any of your habits because of this book? The advice seems really good to me, but I didnt' have any habits to break. I was trying to learn the "right" way before actually getting in too deep which is why I bought the book in the first place.

Replies are listed 'Best First'.
Re: Perl Best Practices for Everyone!
by friedo (Prior) on Nov 09, 2006 at 20:24 UTC

    I don't know if I'm a "seasoned" programmer but I've been doing primarily Perl stuff for the past six years or so.

    When reading PBP, my reactions roughly broke down like this:

    • 80%: That's a good idea. I'm glad I already do it.
    • 10%: That's a good idea. I should start doing it.
    • 10%: That's the worst idea in the history of human civilization and the author should be locked up in a padded room.

    I would say that the middle 10% was the most valuable part of the book, but the first 80% was certainly not worthless. It was good to learn that much more experienced people used a lot of the same habits that I did.

      Actually, after having attended one of that author's talks, and reading some of his modules, I'm not entirely unconvinced about the "should be locked up in a padded room" part myself, and I haven't even read PBP yet ;-)

      i have been programming Perl for about 7 years now.
      When reading PBP, my reactions roughly broke down like this: ...
      same with me, actually. and i guess, most experienced Perl programmers thought so. but this seems logical, since the book is a collection of best practices from many different programmers.
Re: Perl Best Practices for Everyone!
by philcrow (Priest) on Nov 09, 2006 at 20:33 UTC
    As you and others have (and will) point out, much of what is in PBP is confirmation of our ideals. That doesn't mean we always follow them.

    As for what I started doing as a result of reading:

    • I'm much more careful to use single quotes when not interpolating.
    • I created a button in vi to type use Data::Dumper; warn Dumper( );
    • I use warn for all debugging.
    • File handles are now lexical scalars.

    There are probably others, but those are the ones that spring fastest to mind.

    There are some that didn't take with me. I refuse to give up unless. And I don't much like cascading ternaries, since so many people are not used to reading them. I'm not paranoid enough for inside out objects (and they make dumping the object harder).

    None of this is criticism for the book. Damian says it should start a dicussion and lead to careful thought about practices. It did that for me.

    Since you brought it up, I should probably give it another quick read to see if I'm living up to my ideals.


Re: Perl Best Practices for Everyone!
by cog (Parson) on Nov 09, 2006 at 22:55 UTC
    How many of you seasoned programmers have changed any of your habits because of this book?

    Instead of reading the book, I had the opportunity to attend the PBP course in Chicago.

    Not only have I changed some of my habits after the training, I found those teaching so important that I got Damian to come to Portugal and teach them to my team.

    It's *that* good.


      Not only have I changed some of my habits after the training, I found those teaching so important that I got Damian to come to Portugal and teach them to my team.

      :-) This is not true. cog don't program anymore (he was promoted), so it didn't made changes in his programming style.

      But he got Damian to Portugal, and I was one of the lucky bastards to take the two days training, and I really think the teaching very good.

      There are a few things I don't agree with Damian, but I'm changing some of my habits, and some times I'm even looking for my code and thinking if that is the best way to do it, if it is easy to read, and easy to understand.

      Thanks for organizing that training.

        cog don't program anymore

        Sure I do! :-) It's usually only on my free time (and I don't have much of that), but I do! :-) Next time we have lunch I'll take my laptop and I'll show you my latest Catalyst project ;-)

Re: Perl Best Practices for Everyone!
by McDarren (Abbot) on Nov 10, 2006 at 08:26 UTC
    Of the 20+ Perl and Perl-related books I own, PBP is my number two in terms of how useful it has been to me. (Number one is the Camel, of course.)

    I'd been poking around with Perl for a year or two, not really knowing what I was doing when I stumbled across it in a bookstore one day.

    I think the best thing I can say about it is that it gave me some direction - a roadmap of sorts for writing half-decent code that I could look at six months later and still make some sense of.

    So for somebody like you (or me) - somebody who isn't really a professional programmer and hasn't already learned many of these things - I couldn't recommend it highly enough.

    Darren :)

Re: Perl Best Practices for Everyone!
by brig (Scribe) on Nov 10, 2006 at 00:10 UTC

    My number one compaint about the book is that it has been taking up a slot on my Safari bookshelf for 2 weeks and I haven't even looked in it yet. Damn book!

    Of course I am being presumptuous here because I am not really a seasoned Perl programmer, I've been an analyst and a manager far to long to be a good programmer.

    I am now well into chapter 3. First, Wow, I was doing a better job than I thought; of course I really learned how to code from K&R and they were correct to begin with. :)

    Please note, If you have your editor set to convert all tabs to spaces you will run into a problem with Makefiles. Command lines in Makefiles MUST begin with a tab character, spaces will not work. Of course, Damian is writing about perl and what he says is spot on, especially the section on vertical alignment (2.15)


Re: Perl Best Practices for Everyone!
by Velaki (Chaplain) on Nov 10, 2006 at 12:14 UTC

    The Camel is my "Warriner's Grammar."

    PBP is my Strunk & White's, "The Element of Style."

    HOP is my exemplar of masterful expression in Perl.

    Just a farthing,

    "Perl. There is no substitute."
Re: Perl Best Practices for Everyone!
by artist (Parson) on Nov 10, 2006 at 05:24 UTC
    I have enjoyed the book so far. I started to use perltidy which greatly improved readability of my programs.

Re: Perl Best Practices for Everyone!
by sandfly (Beadle) on Nov 13, 2006 at 23:38 UTC
    The big one for me was using a scalar as a filehandle.

    Oh - and underscore_separated_words in variable names. I previously used camelCase, for maximum typing speed. The underscore way does enhance readability.

    I also converted to using inside-out objects, and distict get_ and set_ methods; but I am finding it a chore. This one might not stick.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://583205]
Approved by Corion
Front-paged by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2018-06-21 14:37 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (118 votes). Check out past polls.