Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Brothers and Sisters, I have seen the error of my ways.

I'm a typical bumbling arts graduate who got into perl because there was a job that needed doing and I've spent my perl life bodging things together with chewing gum and string, hardly using any CPAN modules, being promiscuous with my variables and all that bad stuff. This was the Wrong Kind Of Impatience, really, or what you might call Unreasoning Fear of the J Curve. I always thought "hell, by the time I've learned how to do it right I could already have done it wrong".

Well, the disadvantages of working this way have been piling up day by day. Because of course the older and smellier my mess grows, the harder it gets to modify it. And also, in the short while I've been hanging around here I've been inspired to aspire; and I've learnt quite a lot about what I might aspire to.

So I'm repenting. I've junked the bit of my project that I've been working on for the last three weeks (which should have taken less than a week, and which has in any event almost completely disappeared up its own bottom), and I'm starting fresh. I'm going to use strict with -w. I'm going to use CGI or die;. I'm going to indent four cols, line my closing }s up with the start of the loop and cuddle my elses. I'm going to write pseudocode before I start coding and write a plan before I write the pseudocode. I'm localising my variables.

So my question is: What else should I do?

I had a bit of search through the site and read up perlman:perlstyle and a few other relevant nodes. But I'm greedy. I want all the advice I can get. So, if it's ok with you, I'd like to solicit your views on perl Best Practice. The most general programming rules - the BIG stuff. Advice; injunctions; commandments. Thoughts and links. Do you look back and think "if I'd known then what I know now I'd always have...." ? Then I'd be very grateful to hear the what and the why.

(Indeed, for the practices I already mentioned above, I'd love to read why anyway. I mean, I know for example that I should localise my variables, but I'm not 100% clear what makes this such a good thing to do... and one does the right thing much better if one knows why it's the right thing.)

What I'm hoping for, I guess, is a pre-flight checklist of good perl resolutions. I've given this node a generic name in the hope it may in future answer similar questions for other people in my condition - though of course if there already is such a node that I couldn't find, then that's what I'm looking for and I apologise for taking up your time.

George Sherston

In reply to best practice by George_Sherston

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (8)
    As of 2020-10-27 12:17 GMT
    Find Nodes?
      Voting Booth?
      My favourite web site is:

      Results (256 votes). Check out past polls.