Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://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

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (7)
As of 2024-04-16 10:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found