Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Perl Programming guidelines/rules

by davorg (Chancellor)
on Nov 22, 2002 at 11:09 UTC ( [id://215059]=note: print w/replies, xml ) Need Help??


in reply to Perl Programming guidelines/rules

Well, I'd hate to work somewhere that was so perscriptive about how I wrote my code, but here are some specific points:

2. use HTML::Template not HERE documents

HTML::Template and here docs don't really do the same thing (except in a few narrow areas) so that doesn't really make sense. And besides, the Template Toolkit is better :)

5. OO always to be used where possible

That's just silly. It's almost always possible to use OO. It's not always appropriate tho'.

6. Pass by reference

I don't think that means what you think it means. I think you mean "pass references to datastructures into subroutines".

15. Always retrieve database rows into hash reference not arrays

A more usefule rule would be "always explicitly name selected columns in an SQL statement" (aka "don't use SELECT *").

16. Use CGI CARP

What? Even if I'm not writing a CGI program?

17. Assign CGI parameters to hashes

Why?

22. Program flow control to be places in 'main' method

I really don't understand the point of that.

23. No Global Variables

What do you mean by "global variables"? If you mean file-scoped lexicals then they should be avoided, but can often be useful. If you mean package variables then they are often the only to achieve certain things (like sharing variables between packages).

24. use my not local

But there are times when only local will work. I think you meant "prefer lexical variables over package variables".

26. Always use CGI.pm

Again, that seems a bit silly if you're not writing a CGI program.

28. Do not use $_

That rule alone would be sufficient grounds for me to resign on the spot!

29. Do no use goto

At the very least you should make and exception for "goto &sub".

30. Initialise variables

Why? Perl initialises all variable with sensible values.

31. Error handling done using Begin blocks at CGI level. All dies are logged

Another rule that seems unnecessarily CGI-biased.

--
<http://www.dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re: Re: Perl Programming guidelines/rules
by hakkr (Chaplain) on Nov 22, 2002 at 12:15 UTC

    Thanks everybody for a great response it seems I still have a lot to do.

    I'll definitly be adding Code Templates looking at perltidy and refining the list with your comments. Adding some justification for each statement will also be a worthwhile exercise. So sometime soon you may expect the final perlmonk audited list:)

    I think Wally hit it on the head by pointing out what I should have said at the start that this is intended as a list for Novices or bad programmers, new people who join our team and usually have no knowledge of Perl. Perl Gurus are a verifiable rarity and we have so far only managed to hire a couple of people with any real Perl knowledge. A Language migration course is what we really need to help quickly convert them from their native language

    I'm thinking many ways means many guidelines

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://215059]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-24 15:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found